##// END OF EJS Templates
win32: split a utility function to obtain the volume out of getfstype()...
Matt Harbison -
r35530:5cc1becd default
parent child Browse files
Show More
@@ -428,8 +428,9 b' def executablepath():'
428 428 raise ctypes.WinError(_ERROR_INSUFFICIENT_BUFFER)
429 429 return buf.value
430 430
431 def getfstype(path):
432 """Get the filesystem type name from a directory or file (best-effort)
431 def getvolumename(path):
432 """Get the mount point of the filesystem from a directory or file
433 (best-effort)
433 434
434 435 Returns None if we are unsure. Raises OSError on ENOENT, EPERM, etc.
435 436 """
@@ -442,7 +443,16 b' def getfstype(path):'
442 443 if not _kernel32.GetVolumePathNameA(realpath, ctypes.byref(buf), size):
443 444 raise ctypes.WinError() # Note: WinError is a function
444 445
445 t = _kernel32.GetDriveTypeA(buf.value)
446 return buf.value
447
448 def getfstype(path):
449 """Get the filesystem type name from a directory or file (best-effort)
450
451 Returns None if we are unsure. Raises OSError on ENOENT, EPERM, etc.
452 """
453 volume = getvolumename(path)
454
455 t = _kernel32.GetDriveTypeA(volume)
446 456
447 457 if t == _DRIVE_REMOTE:
448 458 return 'cifs'
@@ -453,7 +463,7 b' def getfstype(path):'
453 463 size = 256
454 464 name = ctypes.create_string_buffer(size)
455 465
456 if not _kernel32.GetVolumeInformationA(buf.value, None, 0, None, None, None,
466 if not _kernel32.GetVolumeInformationA(volume, None, 0, None, None, None,
457 467 ctypes.byref(name), size):
458 468 raise ctypes.WinError() # Note: WinError is a function
459 469
General Comments 0
You need to be logged in to leave comments. Login now