[Pythonmac-SIG] appscript path issue

Bill Janssen janssen at parc.com
Fri Mar 6 19:55:57 CET 2009


> Jack Jansen <Jack.Jansen at cwi.nl> wrote:
> 
> > I wouldn't be surprised if the root of the problem is with
> > PowerPoint. It started its life as an OS9 application, so if it still
> > thinks it  lives in an OS9 world with FSSpecs and colon-separated
> > pathnames, it  could be trying to do the conversion to posix paths
> > itself.
> 
> No, it continues to deal with HFS paths.  What I'm getting from it
> is "janssen:Documents" as the directory for the presentation.
> 
> Which implies a disk called "janssen", and a top-level directory called
> "Documents", which is pretty much what's there.
> 
> And osascript processes it correctly, so...
> 
> Bill

So, I thought I'd use FileManager to deal with this, by enumerating the
volumes and their names.  Here's the program I wrote:

#include <CoreServices/CoreServices.h>

int main(int ac, char **av)
{
    /* compile this with:  cc -o test -framework CoreServices test.c */

    OSErr err = 0;
    FSVolumeRefNum actualVolume;
    FSVolumeInfoBitmap whichInfo;
    FSVolumeInfo info;
    HFSUniStr255 volumeName;
    FSRef rootDirectory;

    int i;

    for (i = 1;  err != nsvErr;  i++) {
        volumeName.length = 0;
        err = FSGetVolumeInfo (kFSInvalidVolumeRefNum,
                               i,
                               &actualVolume,
                               kFSVolInfoGettableInfo,
                               &info,
                               &volumeName,
                               &rootDirectory);
        if (err >= 0) {
            char buf[512];
            CFStringRef strRef = CFStringCreateWithCharacters(NULL, // use default allocator
                                                              volumeName.unicode,
                                                              volumeName.length);
            CFStringGetCString(strRef, buf, sizeof(buf), kCFStringEncodingNonLossyASCII);
            printf("%d: %s\n", actualVolume, buf);
        } else if (err != nsvErr) {
            printf("err %d accessing volume %d\n", err, i);
        }
    }
}

When I run it on my machine, with about 15 NFS-mounted volues on it
(according to the "mount" command), it only shows the two actual hard
disks on the machine!  The FileManager reference is pretty unclear about
this; it says "only physical volumes", but discusses AFP and NFS volumes
in talking about FSGetVolumeInfo.

Bill


More information about the Pythonmac-SIG mailing list