Skip navigation.
 
mlgetting information on disk usage
FROM : Alex Reynolds
DATE : Sun Nov 24 12:00:02 2002

I'd like to try to get information about how much space a disk
("newDiskInfoObject") is using at a given time.

I haven't seen anything in NSFileManager to give me this information,
so I looked in Carbon classes and saw FSGetVolumeInfo.

When I implement the following code, volumeInformation.freeBytes is set
to zero, as if it is never retrieved, and so I can't calculate the disk
capacity.

Would anyone know what I am doing incorrect?

Thanks in advance for any pointers -- here's the code I am using:

#include <CoreServices/CoreServices.h>
. . .

@implementation . . .

FSRef fsRef;
FSVolumeInfo volumeInformation;
FSCatalogInfo info;
int error;

NSString *mountpoint = [newDiskInfoObject volumeTruePath];
const char *fsrep = [[NSFileManager defaultManager]
fileSystemRepresentationWithPath:mountpoint];

error = FSPathMakeRef(fsrep, &fsRef, NULL);
if (!error) {
   error = FSGetCatalogInfo(&fsRef, kFSCatInfoVolume,&info, NULL, NULL,
NULL);
   if (!error) {
       FSGetVolumeInfo(info.volume, 0, NULL, kFSVolInfoFSInfo,
&volumeInformation, NULL, NULL);
       [newDiskInfoObject setVolumeFreeSpace: volumeInformation.freeBytes];
   }
}

-Alex
_______________________________________________
cocoa-dev mailing list | <email_removed>
Help/Unsubscribe/Archives: http://www.lists.apple.com/mailman/listinfo/cocoa-dev
Do not post admin requests to the list. They will be ignored.

Related mailsAuthorDate
mlgetting information on disk usage Alex Reynolds Nov 24, 12:00
mlRe: getting information on disk usage Starman Nov 24, 12:53
mlRe: getting information on disk usage Alex Reynolds Nov 24, 23:20