Hi!
I just implemented some routines of BP's Dos unit in a portable way. Some of them are too Dos specific to be done portably, but most of the others are implemented.
What is a bit problematic is the functions DiskSize and DiskFree which return the total or free space of a disk volume (mounted file system), respectively.
The only routine I found to implement them with is statfs() which is unfortunately not standardized. E.g. Linux and DJGPP have compatible statfs()'s, but Solaris' one is a little different and deprecated in favour of statvfs() which isn't present on the former two systems. I don't know what it's like on other systems.
Then I looked at the source code of df(1) which gets this information, and it's full of ifdefs and other nice things which confirms my guess that there's no portable way.
So, I see only the following possibilities:
- Not implement these routines in the Dos unit at all.
- Implement them only for some known systems via ifdefs -- which would be Linux, DJGPP and Solaris for me, and perhaps other people will add support for other systems.
- Test for some known functions (e.g. statfs() with the Linux/DJGPP arguments and statvfs() as found in Solaris) from GPC's RTS configure, and put a little system-independent wrapper into the RTS. (Advantage compared to the previous suggestion: configure is more general than ifdefs and can support systems I don't even know about if they have a compatible routine. Disadvantage: adding support for other systems requires changing the RTS, not only a unit.)
- Pipe the output of df(1) and extract the information from that (not so seriously...)
Any suggestions how to go ahead, or perhaps even better suggestions than the above?
Frank