Page 2 of 2

Re: Getting Free Disk Space

Posted: Tue May 27, 2014 5:02 pm
by NY152
I had a variable that bothered elsewhere in my code, it works perfectly now

Thank you very much for your help: D

Re: Getting Free Disk Space

Posted: Wed Feb 17, 2021 8:17 pm
by JoseT
Hi everybody.

I tried this code but when I call "GetDiskFreeSpaceEx_()" I get the error: "GetDiskFreeSpaceEx_() is not a function, array, list, map or macro".

Perhaps this code is not valid in current version of PureBasic?

Thanks in advance!!

Re: Getting Free Disk Space

Posted: Wed Feb 17, 2021 8:27 pm
by RASHAD
PureBasic demo version don't support Windows API calls

Re: Getting Free Disk Space

Posted: Wed Feb 17, 2021 8:34 pm
by JoseT
RASHAD wrote:PureBasic demo version don't support Windows API calls
Thanks you for you fast answer, but I'm using the full version of PureBasic, not trial.

Re: Getting Free Disk Space

Posted: Thu Feb 18, 2021 5:40 am
by TI-994A
JoseT wrote:...when I call "GetDiskFreeSpaceEx_()" I get the error: "GetDiskFreeSpaceEx_() is not a function, array, list, map or macro".
GetDiskFreeSpaceEx() is a Windows API function, and will not work on MacOS or Linux. This example includes MacOS API calls for similar functionalities:

Code: Select all

Define.q availableSize, totalSize, freeSize

CompilerIf #PB_Compiler_OS = #PB_OS_Windows
  GetDiskFreeSpaceEx_("C:", @availableSize, @totalSize, @freeSize)
CompilerElseIf #PB_Compiler_OS = #PB_OS_MacOS
  fm = CocoaMessage(0, 0, "NSFileManager defaultManager")
  fs = CocoaMessage(0, fm, "attributesOfFileSystemForPath:$", @"/", "error:", #nil)
  sz = CocoaMessage(0, fs, "objectForKey:$", @"NSFileSystemSize")
  fs = CocoaMessage(0, fs, "objectForKey:$", @"NSFileSystemFreeSize")  
  CocoaMessage(@freeSize, sz, "longLongValue")
  CocoaMessage(@totalSize, fs, "longLongValue")
CompilerEndIf

Debug "Total: " + FormatNumber(totalSize, 0) + " bytes"
Debug "Free: " + FormatNumber(freeSize, 0) + " bytes"

Re: Getting Free Disk Space

Posted: Thu Feb 18, 2021 5:56 pm
by JoseT
JoseT wrote:
RASHAD wrote:PureBasic demo version don't support Windows API calls
Thanks you for you fast answer, but I'm using the full version of PureBasic, not trial.
Finally, this problem was solved with reinstallation of PB. I think you are right, my installation was corrupted, I supose.

Thaks a lot!