Changeset 555
- Timestamp:
- 11/10/08 06:38:25 (5 years ago)
- Location:
- trunk
- Files:
-
- 4 edited
-
CHDK/SCRIPTS/TEST/llibtst.lua (modified) (3 diffs)
-
doc/version.txt (modified) (1 diff)
-
lib/lua/loslib.c (modified) (2 diffs)
-
version.inc (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
trunk/CHDK/SCRIPTS/TEST/llibtst.lua
r539 r555 381 381 end 382 382 383 function tlistdir(name,showall) 384 log('os.listdir("',tostring(name),'",',tostring(showall),'): ') 385 local r,msg = os.listdir(name,showall) 386 if r then 387 logok() 388 log("{\n") 389 for k,v in ipairs(r) do 390 log(' ',k,'="',tostring(v),'"\n') 391 end 392 log("}\n") 393 else 394 logfail(tostring(msg)) 395 end 396 return r 397 end 398 383 399 function tutime(name,mtime,atime) 384 400 log('os.utime("',tostring(name),'",',tostring(mtime),',',tostring(atime),'): ') … … 431 447 tstat(tdir0) 432 448 tren(tdir0..tdat0,tdir0..tdat1) 449 tlistdir(tdir0) 450 tlistdir(tdir0,true) 433 451 -- NOTE invalid operations frequently leave the filesystem in a corrupt state 434 452 -- trename(tdir0,tdir1) … … 436 454 trem(tdir0) --fail, not empty 437 455 trem("A/bogus") --fail missing 456 tlistdir("A/bogus") -- missing 457 tlistdir("A/llibtst.log") -- not a directory 438 458 tstat("A/bogus") -- fail missing 439 459 tutime("A/bogus") -- fail missing -
trunk/doc/version.txt
r554 r555 2 2 3 3 version / revision / author 4 0.7.4 / #555 / reyalp 5 + add os.listdir to lua oslib, updated llibtst.lua 6 syntax t=os.listdir("name",[showall]) 7 returns array of filenames, or nil, strerror, errno 8 if showall is true, t includes ".", ".." and deleted entries 9 NOTE except for the root directory, names ending in / will not work 4 10 5 11 0.7.3 / #554 / PhyrePhoX -
trunk/lib/lua/loslib.c
r538 r555 247 247 const char *dirname = luaL_checkstring(L, 1); 248 248 return os_pushresult(L, mkdir(dirname) == 0, dirname); 249 } 250 251 /* 252 syntax 253 t=os.listdir("name",[showall]) 254 returns array of filenames, or nil, strerror, errno 255 if showall is true, t includes ".", ".." and deleted entries 256 NOTE except for the root directory, names ending in / will not work 257 */ 258 static int os_listdir (lua_State *L) { 259 DIR *dir; 260 struct dirent *de; 261 const char *dirname = luaL_checkstring(L, 1); 262 int all=lua_toboolean(L, 2); 263 int i=1; 264 dir = opendir(dirname); 265 if(!dir) 266 return os_pushresult(L, 0 , dirname); 267 lua_newtable(L); 268 while((de = readdir(dir))) { 269 if(!all && (de->name[0] == 0xE5 || (strcmp(de->name,".")==0) || (strcmp(de->name,"..")==0))) 270 continue; 271 lua_pushinteger(L, i); 272 lua_pushstring(L, de->name); 273 lua_settable(L,-3); 274 ++i; 275 } 276 closedir(dir); 277 return 1; 249 278 } 250 279 … … 322 351 #endif 323 352 {"mkdir", os_mkdir}, // reyalp - NOT STANDARD 353 {"listdir", os_listdir}, // reyalp - NOT STANDARD 324 354 {"stat", os_stat}, // reyalp - NOT STANDARD 325 355 {"utime", os_utime}, // reyalp - NOT STANDARD -
trunk/version.inc
r553 r555 1 BUILD_NUMBER := 0.7. 31 BUILD_NUMBER := 0.7.4
Note: See TracChangeset
for help on using the changeset viewer.