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
Date: Sun, 2 Aug 1998 06:15:42 +0200 From: heckenb@helena.hut.fi (Frank Heckenbach) To: gpc@hut.fi Subject: DiskSize and DiskFree
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.
I prefer this approach. I can add the support for Win32. I will try and do this, and send you the sources when I have it working. Perhaps others can do the same for other systems - and then Frank can incorporate them into the source for the DOS unit.
Best regards, The Chief -------- Dr. Abimbola A. Olowofoyeku (The African Chief) Email: laa12@keele.ac.uk Homepage: http://ourworld.compuserve.com/homepages/African_Chief/ Author of: Chief's Installer Pro 4.51 for Win16 and Win32 ftp://ftp.simtel.net/pub/simtelnet/win3/install/chief451.zip