Dinu Gherman wrote: > > "M.-A. Lemburg" wrote: > > > > I think the problem with this one really is the differences > > in OS designs, e.g. on Windows you have the concept of drive > > letters where on Unix you have mounted file systems. Then there > > also is the concept of disk space quota per user which would > > have to be considered too. > > I'd be perfectly happy with something like this: > > import os > free = os.getfreespace('c:\\') # on Win > free = os.getfreespace('/hd5') # on Unix-like boxes > free = os.getfreespace('Mactintosh HD') # on Macs > free = os.getfreespace('ZIP-1') # on Macs, Win, ... > > etc. where the string passed is, a-priori, a name known > by the OS for some permanent or removable drive. Network > drives might be slightly more tricky, but probably not > entirely impossible, I guess. This sounds like a lot of different platform C APIs would need to be wrapped first, e.g. quotactrl, getrlimit (already done) + a bunch of others since "get free space" is usually a file system dependent call. I guess we should take a look at how "df" does this on Unix and maybe trick Mark Hammond into looking up the win32 API ;-) > > Perhaps what we really need is some kind of probing function > > which tests whether a certain amount of disk space would be > > available ?! > > Something like incrementally stuffing it with junk data until > you get an exception, right? :) Yep. Actually opening a file in record mode and then using file.seek() should work on many platforms. -- Marc-Andre Lemburg ______________________________________________________________________ Company & Consulting: http://www.egenix.com/ Python Pages: http://www.lemburg.com/python/
RetroSearch is an open source project built by @garambo | Open a GitHub Issue
Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo
HTML:
3.2
| Encoding:
UTF-8
| Version:
0.7.4