summaryrefslogtreecommitdiffstats
path: root/module/utils.py
diff options
context:
space:
mode:
Diffstat (limited to 'module/utils.py')
-rw-r--r--module/utils.py19
1 files changed, 16 insertions, 3 deletions
diff --git a/module/utils.py b/module/utils.py
index 94bf78054..424aeaf37 100644
--- a/module/utils.py
+++ b/module/utils.py
@@ -117,12 +117,25 @@ def freeSpace(folder):
ctypes.windll.kernel32.GetDiskFreeSpaceExW(ctypes.c_wchar_p(folder), None, None, ctypes.pointer(free_bytes))
return free_bytes.value
else:
- from os import statvfs
-
- s = statvfs(folder)
+ s = os.statvfs(folder)
return s.f_bsize * s.f_bavail
+def fs_bsize(path):
+ """ get optimal file system buffer size (in bytes) for I/O calls """
+ path = fs_encode(path)
+
+ if os.name == "nt":
+ import ctypes
+
+ drive = "%s\\" % os.path.splitdrive(path)[0]
+ cluster_sectors, sector_size = ctypes.c_longlong(0)
+ ctypes.windll.kernel32.GetDiskFreeSpaceW(ctypes.c_wchar_p(drive), ctypes.pointer(cluster_sectors), ctypes.pointer(sector_size), None, None)
+ return cluster_sectors * sector_size
+ else:
+ return os.statvfs(path).f_bsize
+
+
def uniqify(seq, idfun=None):
# order preserving
if idfun is None: