Categories: S60 | Python | Code Examples | How To
Dump file system
From Forum Nokia Wiki
This snippet allows to dump a list of the whole file system to a file with sizes and last modified date. It writes it out to e:/filelog.txt
import os, sys from stat import * import time def walktree(dir, callback): '''recursively descend the directory rooted at dir, calling the callback function for each regular file''' for f in os.listdir(dir): try : pathname = '%s/%s' % (dir, f) mode = os.stat(pathname)[ST_MODE] if S_ISDIR(mode): # It's a directory, recurse into it walktree(pathname, callback) elif S_ISREG(mode): # It's a file, call the callback function callback(pathname) else: # Unknown file type, print a message print 'Skipping %s' % pathname except : pass def visitfile(file): s = os.stat(file) finfo = "%12d %s %s\n" % (s.st_size, time.ctime(s.st_mtime), file) try: log.write(finfo) except: pass if __name__ == '__main__': log = open('e:/filelog.txt', 'w') for drive in ('c:', 'd:', 'e:', 'z:') : walktree(drive, visitfile) log.close()
link : Forum Nokia
| Related Discussions | ||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| filesystem && path | marycore | PersonalJava | 0 | 2002-10-27 20:13 |
| is there a logging-tool for symbian s60? | fallenwout | Bluetooth Technology | 3 | 2007-10-15 18:24 |
| Plea of a Desperate Newbie | akira82 | Symbian Tools & SDKs | 65 | 2006-06-06 03:21 |
| Invoking the default player. | anxamobile | Mobile Java Media (Graphics & Sounds) | 6 | 2006-02-25 11:50 |
| sis file | lone_zing | General Symbian C++ | 3 | 2006-02-03 06:55 |
