[issue410547] os.statvfs support for Windows
Carsten Koch
report at bugs.python.org
Sun Jan 9 15:07:53 CET 2011
Carsten Koch <carstenkoch at users.sourceforge.net> added the comment:
Here is what I am doing now:
...
if sys.platform == "win32":
import win32file
else:
import statvfs
...
def get_free_space(path = '.'):
"""
Determine the free space in bytes for the given path.
"""
if sys.platform == "win32":
sizes = win32file.GetDiskFreeSpace(path)
return sizes[0] * sizes[1] * sizes[2]
else:
status = os.statvfs(path)
return status[statvfs.F_BAVAIL] * status[statvfs.F_FRSIZE]
def get_partition_size(path = '.'):
"""
Determine the total space in bytes for the given path.
"""
if sys.platform == "win32":
sizes = win32file.GetDiskFreeSpace(path)
return sizes[0] * sizes[1] * sizes[3]
else:
status = os.statvfs(path)
return status[statvfs.F_BLOCKS] * status[statvfs.F_FRSIZE]
----------
versions: +Python 2.6
_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue410547>
_______________________________________
More information about the Python-bugs-list
mailing list