ViewVC Help
View File | Revision Log | Show Annotations | View Changeset | Root Listing
root/ns_dev/Python/NinoCode/Active_prgs/directorySize.py
Revision: 8
Committed: Sat May 5 04:21:19 2012 UTC (13 years, 10 months ago) by ninoborges
Content type: text/x-python
File size: 636 byte(s)
Log Message:
Initial Import

File Contents

# User Rev Content
1 ninoborges 8 import win32file, os
2    
3     def get_dir_size(path):
4     total_size = 0
5     if os.sys.platform == 'win32':
6     try:
7     items = win32file.FindFilesW(path + '\\*')
8     except Exception, err:
9     return 0
10    
11     # Add the size or perform recursion on folders.
12     for item in items:
13     attr = item[0]
14     name = item[-2]
15     size = item[5]
16    
17     # if (attr & win32con.FILE_ATTRIBUTE_DIRECTORY) and \
18     # not (attr & win32con.FILE_ATTRIBUTE_SYSTEM): # skip system dirs
19     # if name not in DIR_EXCLUDES:
20     total_size += get_dir_size("%s\\%s" % (path, name))
21    
22     total_size += size
23    
24     return total_size