X-Git-Url: http://www.aleph1.co.uk/gitweb/?a=blobdiff_plain;f=direct%2Fpython%2Fexamples.py;h=349e234453c8f0e7660e3cb17a039ebff136dadc;hb=2334d4199580ecca3059056b773213fae4cbe01d;hp=6b40080432ea237122d392da1f2216c4a1b6d580;hpb=22e75ceb6885637cc22f864270d04ea83354548d;p=yaffs2.git diff --git a/direct/python/examples.py b/direct/python/examples.py index 6b40080..349e234 100644 --- a/direct/python/examples.py +++ b/direct/python/examples.py @@ -17,15 +17,35 @@ def yaffs_ls(dname): if isFile : print "File ",se.d_ino, hex(perms), st.st_size, fullname - if isDir : + elif isDir : print "Dir ",se.d_ino, hex(perms), fullname yaffs_ls(fullname) - + else : + print "Other (",hex(st.st_mode),") ",se.d_ino, hex(perms), fullname + sep = yaffs_readdir(dc) + yaffs_closedir(dc) + return 0 else: print "Could not open directory" return -1 +def yaffs_mkfile(fname,fsize): + fd = yaffs_open(fname,66, 0666) + if fd >= 0: + b = create_string_buffer("",1024) + totalwrite=0 + while fsize > 0: + thiswrite = 1024 if fsize > 1024 else fsize + result = yaffs_write(fd,b,thiswrite) + totalwrite += result + fsize -= result + if result != thiswrite: + fsize= 0 + + return totalwrite + else : + return -1 root = "/yaffs2"