, 90% FindFilesW(). , Python .
( FindFilesW) , DIR_EXCLUDES - , [] , sys.platform . , , 1-2% .
DIR_EXCLUDES = set(['.', '..'])
MASK = win32con.FILE_ATTRIBUTE_DIRECTORY | win32con.FILE_ATTRIBUTE_SYSTEM
REQUIRED = win32con.FILE_ATTRIBUTE_DIRECTORY
FindFilesW = win32file.FindFilesW
def get_dir_size(path):
total_size = 0
try:
items = FindFilesW(path + r'\*')
except pywintypes.error, ex:
return total_size
for item in items:
total_size += item[5]
if (item[0] & MASK == REQUIRED):
name = item[8]
if name not in DIR_EXCLUDES:
total_size += get_dir_size(path + '\\' + name)
return total_size
API . , , , . , FindFirstChangeNotification API - . , ( ), , , ( ), , .
: , , Windows XP . ( ) Windows, C:\ Alt-Enter, . ( ) 40 , 20- . , , Windows, , .