Show More
@@ -428,8 +428,9 b' def executablepath():' | |||||
428 | raise ctypes.WinError(_ERROR_INSUFFICIENT_BUFFER) |
|
428 | raise ctypes.WinError(_ERROR_INSUFFICIENT_BUFFER) | |
429 | return buf.value |
|
429 | return buf.value | |
430 |
|
430 | |||
431 |
def get |
|
431 | def getvolumename(path): | |
432 |
"""Get the filesystem |
|
432 | """Get the mount point of the filesystem from a directory or file | |
|
433 | (best-effort) | |||
433 |
|
434 | |||
434 | Returns None if we are unsure. Raises OSError on ENOENT, EPERM, etc. |
|
435 | Returns None if we are unsure. Raises OSError on ENOENT, EPERM, etc. | |
435 | """ |
|
436 | """ | |
@@ -442,7 +443,16 b' def getfstype(path):' | |||||
442 | if not _kernel32.GetVolumePathNameA(realpath, ctypes.byref(buf), size): |
|
443 | if not _kernel32.GetVolumePathNameA(realpath, ctypes.byref(buf), size): | |
443 | raise ctypes.WinError() # Note: WinError is a function |
|
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 | if t == _DRIVE_REMOTE: |
|
457 | if t == _DRIVE_REMOTE: | |
448 | return 'cifs' |
|
458 | return 'cifs' | |
@@ -453,7 +463,7 b' def getfstype(path):' | |||||
453 | size = 256 |
|
463 | size = 256 | |
454 | name = ctypes.create_string_buffer(size) |
|
464 | name = ctypes.create_string_buffer(size) | |
455 |
|
465 | |||
456 |
if not _kernel32.GetVolumeInformationA( |
|
466 | if not _kernel32.GetVolumeInformationA(volume, None, 0, None, None, None, | |
457 | ctypes.byref(name), size): |
|
467 | ctypes.byref(name), size): | |
458 | raise ctypes.WinError() # Note: WinError is a function |
|
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