using unknown api calls with purebasic

Linux specific forum
Bitblazer
Enthusiast
Enthusiast
Posts: 733
Joined: Mon Apr 10, 2017 6:17 pm
Location: Germany
Contact:

using unknown api calls with purebasic

Post by Bitblazer »

I Have an old project that used the statfs call in the past, but im unable to get it to compile with purebasic 5.61 beta 1. Using the pbsoimporter as mentioned here http://www.purebasic.fr/english/viewtop ... lit=statfs neither worked in the amd64 nor the x86 version of linux 5.61 beta 1

Code: Select all

StatFSBuffer$ = Space(200)

  Res = statfs_(Path$, @StatFSBuffer$)
  
  If (Res = 0)
    Blocks.i = PeekL(@StatFSBuffer$ + 16)
  endif
PB 5.61 beta 1 seems unable to resolve the api call and just aborts compilation with
[13:11:57] [COMPILER] Line 480: statfs_() is not a function, array, list, map or macro.
Is it my mistake or a 5.61 beta problem?

ps: installing a previous major version now to see if that works
webpage - discord chat links -> purebasic GPT4All
User avatar
Shardik
Addict
Addict
Posts: 1989
Joined: Thu Apr 21, 2005 2:38 pm
Location: Germany

Re: using unknown api calls with purebasic

Post by Shardik »

You shouldn't use statfs anymore because it's deprecated and OS-specific. Instead of statfs you should use statvfs because it's POSIX compliant and handles large file sizes better.

You have to use the following ImportC statement (and also define the structure of statvfs before this import) for PureBasic to resolve the API call:

Code: Select all

ImportC ""
  statvfs(Path.P-UTF8, *Buffer.statvfs)
EndImport
You may take a look into remi_meier's example or uwekel's example (which is derived from remi_meier's one and reports a volume's space, used space and free space).
Post Reply