×
Namespaces

Variants
Actions
(Redirected from Dump file system)

Archived:Dump file system using PySymbian

From Nokia Developer Wiki
Jump to: navigation, search

Archived.pngAquivado: Este artigo foi arquivado, pois o conteúdo não é mais considerado relevante para se criar soluções comerciais atuais. Se você achar que este artigo ainda é importante, inclua o template {{ForArchiveReview|escreva a sua justificativa}}.

All PySymbian articles have been archived. PySymbian is no longer maintained by Nokia and is not guaranteed to work on more recent Symbian devices. It is not possible to submit apps to Nokia Store.

Article Metadata
Tested with
Devices(s): S60 3rd Edition FP1 SDK
Compatibility
Platform(s): S60 2nd Edition, S60 3rd Edition
Article
Keywords: os
Created: cyke64 (03 Apr 2007)
Last edited: hamishwillee (31 May 2013)

Contents

Introduction

This snippet allows to dump a list of the whole file system to a file with sizes and last modified date.

Preconditions

The memory card should be presented as the file path is subject to E:. If not then the file should be created on C:.

Code Snippet

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()

Post Conditions

E:/filelog.txt file is created.

Related Links

This page was last modified on 31 May 2013, at 04:03.
58 page views in the last 30 days.

Was this page helpful?

Your feedback about this content is important. Let us know what you think.

 

Thank you!

We appreciate your feedback.

×