# HG changeset patch # User Matt Harbison # Date 1514603737 18000 # Node ID 5cc1becd04934b927c67ebac25098dace9badec1 # Parent d8f408d999f919ee10057aa8640a6a41d2097c2b win32: split a utility function to obtain the volume out of getfstype() This is only done on Windows because it's simple enough to call statfs() on Unix. The goal is to display this in `hg debugfs`. diff -r d8f408d999f9 -r 5cc1becd0493 mercurial/win32.py --- a/mercurial/win32.py Sat Dec 30 21:15:12 2017 -0500 +++ b/mercurial/win32.py Fri Dec 29 22:15:37 2017 -0500 @@ -428,8 +428,9 @@ raise ctypes.WinError(_ERROR_INSUFFICIENT_BUFFER) return buf.value -def getfstype(path): - """Get the filesystem type name from a directory or file (best-effort) +def getvolumename(path): + """Get the mount point of the filesystem from a directory or file + (best-effort) Returns None if we are unsure. Raises OSError on ENOENT, EPERM, etc. """ @@ -442,7 +443,16 @@ if not _kernel32.GetVolumePathNameA(realpath, ctypes.byref(buf), size): raise ctypes.WinError() # Note: WinError is a function - t = _kernel32.GetDriveTypeA(buf.value) + return buf.value + +def getfstype(path): + """Get the filesystem type name from a directory or file (best-effort) + + Returns None if we are unsure. Raises OSError on ENOENT, EPERM, etc. + """ + volume = getvolumename(path) + + t = _kernel32.GetDriveTypeA(volume) if t == _DRIVE_REMOTE: return 'cifs' @@ -453,7 +463,7 @@ size = 256 name = ctypes.create_string_buffer(size) - if not _kernel32.GetVolumeInformationA(buf.value, None, 0, None, None, None, + if not _kernel32.GetVolumeInformationA(volume, None, 0, None, None, None, ctypes.byref(name), size): raise ctypes.WinError() # Note: WinError is a function