Free Disk Space on drive

Mac OSX specific forum
spacebuddy
Enthusiast
Enthusiast
Posts: 356
Joined: Thu Jul 02, 2009 5:42 am

Free Disk Space on drive

Post by spacebuddy »

Is there anyway to get the free disk space on the hard drive?
User avatar
J. Baker
Addict
Addict
Posts: 2181
Joined: Sun Apr 27, 2003 8:12 am
Location: USA
Contact:

Re: Free Disk Space on drive

Post by J. Baker »

Yes there is... ;)

attributesOfFileSystemForPath:error:
www.posemotion.com

PureBasic Tools for OS X: PureMonitor, plist Tool, Data Maker & App Chef


Even the vine knows it surroundings but the man with eyes does not.
spacebuddy
Enthusiast
Enthusiast
Posts: 356
Joined: Thu Jul 02, 2009 5:42 am

Re: Free Disk Space on drive

Post by spacebuddy »

I did a search in the help file for attributesOfFileSystemForPath:error: but could not find it :D
User avatar
J. Baker
Addict
Addict
Posts: 2181
Joined: Sun Apr 27, 2003 8:12 am
Location: USA
Contact:

Re: Free Disk Space on drive

Post by J. Baker »

spacebuddy wrote:I did a search in the help file for attributesOfFileSystemForPath:error: but could not find it :D
It won't be in the PureBasic help file, it's Cocoa.
https://www.google.com/search?client=sa ... 8&oe=UTF-8
www.posemotion.com

PureBasic Tools for OS X: PureMonitor, plist Tool, Data Maker & App Chef


Even the vine knows it surroundings but the man with eyes does not.
spacebuddy
Enthusiast
Enthusiast
Posts: 356
Joined: Thu Jul 02, 2009 5:42 am

Re: Free Disk Space on drive

Post by spacebuddy »

Okay I tried this but I keep getting 0 bytes back

Global attr = CocoaMessage(0, CocoaMessage(0, 0, "NSFM"), "attributesOfFileSystemForPath:error")
bytesFree=CocoaMessage(0,attr,"objectForKey:NSFileSystemFreeSize")
wilbert
PureBasic Expert
PureBasic Expert
Posts: 3942
Joined: Sun Aug 08, 2004 5:21 am
Location: Netherlands

Re: Free Disk Space on drive

Post by wilbert »

Code: Select all

Define FreeSize.q
Define FileManager = CocoaMessage(0, 0, "NSFileManager defaultManager")
Define Attributes = CocoaMessage(0, FileManager, "attributesOfFileSystemForPath:$", @"/", "error:", #nil)
CocoaMessage(@FreeSize, CocoaMessage(0, Attributes, "objectForKey:$", @"NSFileSystemFreeSize"), "longLongValue")

Debug FreeSize
Windows (x64)
Raspberry Pi OS (Arm64)
spacebuddy
Enthusiast
Enthusiast
Posts: 356
Joined: Thu Jul 02, 2009 5:42 am

Re: Free Disk Space on drive

Post by spacebuddy »

Thanks wilbert :D
Post Reply