Getting Free Disk Space

Windows specific forum
NY152
User
User
Posts: 29
Joined: Sun May 14, 2006 12:33 am

Re: Getting Free Disk Space

Post by NY152 »

I had a variable that bothered elsewhere in my code, it works perfectly now

Thank you very much for your help: D
.:NY152:.
JoseT
User
User
Posts: 14
Joined: Sun Dec 06, 2020 11:27 am

Re: Getting Free Disk Space

Post 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!!
Regards,
JT
RASHAD
PureBasic Expert
PureBasic Expert
Posts: 4636
Joined: Sun Apr 12, 2009 6:27 am

Re: Getting Free Disk Space

Post by RASHAD »

PureBasic demo version don't support Windows API calls
Egypt my love
JoseT
User
User
Posts: 14
Joined: Sun Dec 06, 2020 11:27 am

Re: Getting Free Disk Space

Post 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.
Regards,
JT
User avatar
TI-994A
Addict
Addict
Posts: 2512
Joined: Sat Feb 19, 2011 3:47 am
Location: Singapore
Contact:

Re: Getting Free Disk Space

Post 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"
Texas Instruments TI-99/4A Home Computer: the first home computer with a 16bit processor, crammed into an 8bit architecture. Great hardware - Poor design - Wonderful BASIC engine. And it could talk too! Please visit my YouTube Channel :D
JoseT
User
User
Posts: 14
Joined: Sun Dec 06, 2020 11:27 am

Re: Getting Free Disk Space

Post 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!
Regards,
JT
Post Reply