fork/m-overlay
git clone https://git.julia.blue/fork/m-overlay
2c3d0c1
v2.1.1b
1local ffi =require ( "ffi" ) 2local libc =ffi . C 3local errno =ffi . errno 4 5ffi . cdef [[ 6typedef struct { 7ino_t d_ino ; /* Inode number */ 8off_t d_off ; /* Not an offset; see below */ 9unsigned short d_reclen ; /* Length of this record */ 10unsigned char d_type ; /* Type of file; not supported 11by all filesystem types */ 12char name [ 256 ]; /* Null-terminated filename */ 13} dirent ; 14typedef struct __dirstream DIR ; 15 16char * strerror ( int errnum ); 17DIR * opendir ( const char * name ); 18int closedir ( DIR * dirp ); 19dirent * readdir ( DIR * dirp ); 20]] 21 22local linux ={} 23 24function linux . getItems ( path ) 25local dir =libc . opendir ( path ) 26local entries ={} 27 28if dir ~= nil then 29local entry 30while true do 31entry =libc . readdir ( dir ) 32if entry == nil then break end -- end of list 33local name =ffi . string ( entry . name ) 34if name ~= "." and name ~= ".." then 35table . insert ( entries , name ) 36end 37end 38libc . closedir ( dir ) 39end 40 41return entries 42end 43 44return linux