Mailing Lists: Apple Mailing Lists

Image of Mac OS face in stamp
 
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

FSGetVolumeInfo does not get updated volume info on mounts/dismounts (Tiger)




I have an application that needs to find any mounted CDs and get their TOCs.
It pretty much works under Panther, but in Tiger I get the following problem:


When calling FSGetVolumeInfo and iterating over the volumes, the first time I call it, it works fine. It returns me the volRef numbers -100, -101 (for the 2 drives I always have mounted), and -112 (for example) for the currently mounted CD.

Then I eject the CD, and load a different CD, and run that code again (during the same run of the program).

The I get -100, -101, and -112 *again*! And -112 is no longer a valid ref number.

If I quit the program and re-launch it correctly identifies -113 as the new CD's volume reference.

This problem is not limited to CDs - it also occurs when mounting/ dismounting iPods, for example.

My guess is that once I call FSGetVolumeInfo, it caches the volumes for the lifespan of the current process.

Is this a bug in Tiger? And can anyone think of any way around it? Is there any way to flush the File Manager's cache of volume information?

Thanks,
-Arshad

Here's the code I'm using (approximately):


while (1) /* bug occurs when the code runs more than once during the process' lifetime */
{
char x[1024];
gets(x); /* this makes it prompt me, if I hit enter it will re-scan for volumes */
findalltocs();
printf("Reading....\n");
result = noErr;



short ref = GetDefaultAudioCDRefNum(); printf("ref : %d\n", ref);

for (volumeIndex = 1; result == noErr || result != nsvErr; volumeIndex++)
{
FSVolumeRefNum actualVolume;
HFSUniStr255 volumeName;
FSVolumeInfo volumeInfo;


            bzero((void *) &volumeInfo, sizeof(volumeInfo));

            result = FSGetVolumeInfo(kFSInvalidVolumeRefNum,
                                     volumeIndex,
                                     &actualVolume,
                                     kFSVolInfoFSInfo,
                                     &volumeInfo,
                                     &volumeName,
                                     NULL);

printf("Vol %d %d\n", volumeIndex, actualVolume); /* actual volume is the volume ref */
...
}
}


_______________________________________________
Do not post admin requests to the list. They will be ignored.
Carbon-dev mailing list      (email@hidden)
Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/carbon-dev/email@hidden

This email sent to email@hidden


Visit the Apple Store online or at retail locations.
1-800-MY-APPLE

Contact Apple | Terms of Use | Privacy Policy

Copyright © 2007 Apple Inc. All rights reserved.