comparison direct/python/examples.py @ 322:1206ae06f03d

More python example stuff
author charles
date Tue, 13 Oct 2009 04:20:05 +0100
parents fd8194c28cac
children
comparison
equal deleted inserted replaced
321:fd8194c28cac 322:1206ae06f03d
20 if isDir : 20 if isDir :
21 print "Dir ",se.d_ino, hex(perms), fullname 21 print "Dir ",se.d_ino, hex(perms), fullname
22 yaffs_ls(fullname) 22 yaffs_ls(fullname)
23 23
24 sep = yaffs_readdir(dc) 24 sep = yaffs_readdir(dc)
25 yaffs_closedir(dc)
26 return 0
25 else: 27 else:
26 print "Could not open directory" 28 print "Could not open directory"
27 return -1 29 return -1
28 30
31 def yaffs_mkfile(fname,fsize):
32 fd = yaffs_open(fname,66, 0666)
33 if fd >= 0:
34 b = create_string_buffer("",1024)
35 totalwrite=0
36 while fsize > 0:
37 thiswrite = 1024 if fsize > 1024 else fsize
38 result = yaffs_write(fd,b,thiswrite)
39 totalwrite += result
40 fsize -= result
41 if result != thiswrite:
42 fsize= 0
43
44 return totalwrite
45 else :
46 return -1
29 47
30 root = "/yaffs2" 48 root = "/yaffs2"
31 49
32 yaffs_StartUp() 50 yaffs_StartUp()
33 yaffs_mount(root) 51 yaffs_mount(root)