[Openmcl-devel] default volume name
gb at clozure.com
Fri Sep 20 21:34:08 UTC 2002
On Fri, 20 Sep 2002, John DeSoi wrote:
> Is there a way to get the default volume in OpenMCL? I have a strange
> (hopefully temporary) situation with a ported library. The file
> operations require a FSSpec record. The good news is that I can call
> #_FSMakeFSSpec in OpenMCL. The bad news is that this function expects
> a Mac style path name with ":" as the directory separator. So as a
> temporary fix, I wanted to convert something like:
> /Folder/file.txt to MyVol:Folder:file.txt.
> Is there a better solution? Maybe I just need some other OS X API call?
My impression is that OSX represents paths internally (at the "Core
Foundation" level, at least) as URL objects ("CFURLRef"s.)
I think that the general idea is to create a CFURLRef from a POSIX
(/-delimited) path via #_CFURLCreateFromFileSystemRepresentation,
then extract an HFS path from that URL via #_CFURLCopyFileSystemPath.
(Note that both of these functions take "CFURLPathStyle" arguments.)
CF functions tend to deal with Unicode string objects called (not
surprisingly) "CFString"s. I remember writing code once that did
what the CFSTR C macro does (creates a constant CFString from a
specified C string); I'm not sure where that code is, but I remember
that the procedure was pretty simple.
CF objects are reference-counted (constant CFStrings might be an
CF is used by both Carbon and Cocoa, but isn't built-in to "libSystem"
(the C/math/some other stuff library that OpenMCL's linked against.) You
? (open-shared-library "/System/Library/Frameworks/CoreFoundation.framework/CoreFoundation")
if you don't want to load all of Carbon or Cocoa.
? (use-interface-dir :carbon)
will make the constants, types/records, and function definitions available.
Hope this helps. (Note that actual code is left as an exercise ...)
I don't know of a simpler way to translate between pathname representations.
> John DeSoi, Ph.D.
> Openmcl-devel mailing list
> Openmcl-devel at clozure.com
Openmcl-devel mailing list
Openmcl-devel at clozure.com
More information about the Openmcl-devel