def getvolumeinfo(path):
"""
Return information for the volume containing the given path. This is going
to be a pair containing (file system, file system flags).
"""
# Add 1 for a trailing backslash if necessary, and 1 for the terminating
# null character.
volpath = ctypes.create_unicode_buffer(len(path) + 2)
rv = GetVolumePathName(path, volpath, len(volpath))
if rv == 0:
raise WinError()
fsnamebuf = ctypes.create_unicode_buffer(MAX_PATH + 1)
fsflags = DWORD(0)
rv = GetVolumeInformation(volpath, None, 0, None, None, byref(fsflags),
fsnamebuf, len(fsnamebuf))
if rv == 0:
raise WinError()
return (fsnamebuf.value, fsflags.value)
评论列表
文章目录