• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
getting information on disk usage
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

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.

  • Follow-Ups:
    • Re: getting information on disk usage
      • From: Starman <email@hidden>
  • Prev by Date: Re: An interesting localisation issue
  • Next by Date: Re: An interesting localisation issue
  • Previous by thread: Re: transparent views and window shadow interference
  • Next by thread: Re: getting information on disk usage
  • Index(es):
    • Date
    • Thread