Page 1 of 1

Free Disk Space on drive

Posted: Sun Mar 03, 2013 5:34 pm
by spacebuddy
Is there anyway to get the free disk space on the hard drive?

Re: Free Disk Space on drive

Posted: Sun Mar 03, 2013 6:16 pm
by J. Baker
Yes there is... ;)

attributesOfFileSystemForPath:error:

Re: Free Disk Space on drive

Posted: Sun Mar 03, 2013 6:24 pm
by spacebuddy
I did a search in the help file for attributesOfFileSystemForPath:error: but could not find it :D

Re: Free Disk Space on drive

Posted: Sun Mar 03, 2013 7:24 pm
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

Re: Free Disk Space on drive

Posted: Sun Mar 03, 2013 8:35 pm
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")

Re: Free Disk Space on drive

Posted: Sun Mar 03, 2013 8:54 pm
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

Re: Free Disk Space on drive

Posted: Sun Mar 03, 2013 9:15 pm
by spacebuddy
Thanks wilbert :D