本文整理汇总了Python中win32api.GetVolumeInformation方法的典型用法代码示例。如果您正苦于以下问题:Python win32api.GetVolumeInformation方法的具体用法?Python win32api.GetVolumeInformation怎么用?Python win32api.GetVolumeInformation使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类win32api
的用法示例。
在下文中一共展示了win32api.GetVolumeInformation方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: MakeNTFSFilesGlobalWriteable
# 需要导入模块: import win32api [as 别名]
# 或者: from win32api import GetVolumeInformation [as 别名]
def MakeNTFSFilesGlobalWriteable(self, pathToSet=None):
if not self.WIN32:
return
import win32api
if pathToSet == None:
pathToSet = self.getInstallDir()
else:
pathToSet = pathToSet.cStr() + '*'
DrivePath = pathToSet[0:3]
try:
volname, volsernum, maxfilenamlen, sysflags, filesystemtype = win32api.GetVolumeInformation(DrivePath)
except:
return
if self.win32con_FILE_PERSISTENT_ACLS & sysflags:
self.notify.info('NTFS detected, making files global writeable\n')
win32dir = win32api.GetWindowsDirectory()
cmdLine = win32dir + '\\system32\\cacls.exe "' + pathToSet + '" /T /E /C /G Everyone:F > nul'
os.system(cmdLine)
return
示例2: check_drives
# 需要导入模块: import win32api [as 别名]
# 或者: from win32api import GetVolumeInformation [as 别名]
def check_drives():
for drive in win32api.GetLogicalDriveStrings().split("\x00"):
sys.stdout.write(".")
type = win32file.GetDriveType(drive)
if type == win32con.DRIVE_FIXED:
fs = win32api.GetVolumeInformation(drive)[4]
if fs == 'NTFS':
warning = ""
weak_perms = check_weak_write_perms(drive, 'directory')
if weak_perms:
# print "Weak permissions on drive root %s:" % drive
# print_weak_perms('directory', weak_perms)
sys.stdout.write(".")
save_issue("WPC010", "writable_drive_root", weak_perms)
elif fs == 'FAT':
save_issue_string("WPC011", "fat_fs_drives", "Fixed drive " + drive + ": has " + fs + " filesystem (FAT does not support file permissions)" )
sys.stdout.write("!")
elif fs == 'FAT32':
save_issue_string("WPC011", "fat_fs_drives", "Fixed drive " + drive + ": has " + fs + " filesystem (FAT32 does not support file permissions)" )
sys.stdout.write("!")
else:
warning = " (not NTFS - might be insecure)"
save_issue_string("WPC011", "fat_fs_drives", "Fixed drive " + drive + ": has " + fs + " filesystem (Not NTFS - might not be secure)" )
sys.stdout.write("!")
# print "Fixed drive %s has %s filesystem%s" % (drive, fs, warning)
print
示例3: get_sparse_files_support
# 需要导入模块: import win32api [as 别名]
# 或者: from win32api import GetVolumeInformation [as 别名]
def get_sparse_files_support(path):
supported = False
if os.name == 'nt':
drive, path = os.path.splitdrive(os.path.abspath(path))
if len(drive) > 0: # might be a network path
if drive[-1] != '\\':
drive += '\\'
volumename, serialnumber, maxpath, fsflags, fs_name = win32api.GetVolumeInformation(drive)
if fsflags & FILE_SUPPORTS_SPARSE_FILES:
supported = True
return supported
# is there a linux max path?
示例4: get_max_filesize
# 需要导入模块: import win32api [as 别名]
# 或者: from win32api import GetVolumeInformation [as 别名]
def get_max_filesize(path):
fs_name = None
# optimistic if we can't tell
max_filesize = 2**64
if os.name == 'nt':
drive, path = os.path.splitdrive(os.path.abspath(path))
if len(drive) > 0: # might be a network path
if drive[-1] != '\\':
drive += '\\'
volumename, serialnumber, maxpath, fsflags, fs_name = win32api.GetVolumeInformation(drive)
if fs_name == "FAT32":
max_filesize = 2**32 - 1
elif (fs_name == "FAT" or
fs_name == "FAT16"):
# information on this varies, so I chose the description from
# MS: http://support.microsoft.com/kb/q118335/
# which happens to also be the most conservative.
max_clusters = 2**16 - 11
max_cluster_size = 2**15
max_filesize = max_clusters * max_cluster_size
else:
path = os.path.realpath(path)
# not implemented yet
#fsname = crawl_path_for_mount_entry(path)
return fs_name, max_filesize