getting information on disk usage
getting information on disk usage
- Subject: getting information on disk usage
- From: Alex Reynolds <email@hidden>
- Date: Sun, 24 Nov 2002 06:00:02 -0500
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@hidden
Help/Unsubscribe/Archives:
http://www.lists.apple.com/mailman/listinfo/cocoa-dev
Do not post admin requests to the list. They will be ignored.