From 22e75ceb6885637cc22f864270d04ea83354548d Mon Sep 17 00:00:00 2001 From: charles Date: Tue, 13 Oct 2009 01:28:21 +0000 Subject: [PATCH] Add some python examples --- direct/python/examples.py | 39 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 39 insertions(+) create mode 100644 direct/python/examples.py diff --git a/direct/python/examples.py b/direct/python/examples.py new file mode 100644 index 0000000..6b40080 --- /dev/null +++ b/direct/python/examples.py @@ -0,0 +1,39 @@ +from yaffsfs import * + +def yaffs_ls(dname): + if dname[-1] != "/": dname = dname + "/" + dc = yaffs_opendir(dname) + if dc != 0 : + sep = yaffs_readdir(dc) + while bool(sep): + se = sep.contents + fullname = dname + se.d_name + #print fullname, " ", se.d_ino," ",ord(se.d_type) + st = yaffs_stat_struct() + result = yaffs_stat(fullname,byref(st)) + perms = st.st_mode & 0777 + isFile = True if st.st_mode & 0x8000 else False + isDir = True if st.st_mode & 0x4000 else False + + if isFile : + print "File ",se.d_ino, hex(perms), st.st_size, fullname + if isDir : + print "Dir ",se.d_ino, hex(perms), fullname + yaffs_ls(fullname) + + sep = yaffs_readdir(dc) + else: + print "Could not open directory" + return -1 + + +root = "/yaffs2" + +yaffs_StartUp() +yaffs_mount(root) + +yaffs_mkdir(root+"/dd",0666) + +yaffs_open(root+"/dd/111",66,0666) + +yaffs_ls(root) -- 2.30.2