yaffs-ecoscentric
changeset 321:fd8194c28cac
Add some python examples
| author | charles |
|---|---|
| date | Tue Oct 13 02:28:21 2009 +0100 (2009-10-13) |
| parents | e239e0b8c57d |
| children | 1206ae06f03d |
| files | direct/python/examples.py |
line diff
1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/direct/python/examples.py Tue Oct 13 02:28:21 2009 +0100 1.3 @@ -0,0 +1,39 @@ 1.4 +from yaffsfs import * 1.5 + 1.6 +def yaffs_ls(dname): 1.7 + if dname[-1] != "/": dname = dname + "/" 1.8 + dc = yaffs_opendir(dname) 1.9 + if dc != 0 : 1.10 + sep = yaffs_readdir(dc) 1.11 + while bool(sep): 1.12 + se = sep.contents 1.13 + fullname = dname + se.d_name 1.14 + #print fullname, " ", se.d_ino," ",ord(se.d_type) 1.15 + st = yaffs_stat_struct() 1.16 + result = yaffs_stat(fullname,byref(st)) 1.17 + perms = st.st_mode & 0777 1.18 + isFile = True if st.st_mode & 0x8000 else False 1.19 + isDir = True if st.st_mode & 0x4000 else False 1.20 + 1.21 + if isFile : 1.22 + print "File ",se.d_ino, hex(perms), st.st_size, fullname 1.23 + if isDir : 1.24 + print "Dir ",se.d_ino, hex(perms), fullname 1.25 + yaffs_ls(fullname) 1.26 + 1.27 + sep = yaffs_readdir(dc) 1.28 + else: 1.29 + print "Could not open directory" 1.30 + return -1 1.31 + 1.32 + 1.33 +root = "/yaffs2" 1.34 + 1.35 +yaffs_StartUp() 1.36 +yaffs_mount(root) 1.37 + 1.38 +yaffs_mkdir(root+"/dd",0666) 1.39 + 1.40 +yaffs_open(root+"/dd/111",66,0666) 1.41 + 1.42 +yaffs_ls(root)
