Changeset 55
Legend:
- Unmodified
- Added
- Removed
-
trunk/lua/chdku.lua
r54 r55 456 456 end 457 457 for i,name in ipairs(filenames) do 458 local src = srcpath .. '/' .. name459 local dst = dstpath .. '/' .. name458 local src = joinpath(srcpath,name) 459 local dst = joinpath(dstpath,name) 460 460 printf("%s -> %s\n",src,dst) 461 461 status,err = chdk.download(src,dst) 462 462 if not status then 463 463 return status,err 464 end 465 end 466 return true 467 end 468 --[[ 469 quick and dirty bulk delete, this may change or go away 470 471 delete files from directory, optionally matching pattern 472 note directory should not end in a /, unless it is A/ 473 only *files* will be deleted, directories will not be touched 474 ]] 475 function chdku.deletefiles(dir,pattern) 476 local files,err=chdku.listdir(dir,{stat="*",match=pattern}) 477 if not files then 478 return false, err 479 end 480 for i,st in ipairs(files) do 481 if st.is_file then 482 local status,err=chdku.execwait("return os.remove('"..joinpath(dir,st.name).."')") 483 if not status then 484 return false,err 485 end 486 -- print('del '..st.name) 464 487 end 465 488 end … … 755 778 end 756 779 end 757 --[[758 quick and dirty bulk delete, this may change or go away759 760 delete files from directory, optionally matching pattern761 note directory should not end in a /, unless it is A/762 only *files* will be deleted, directories will not be touched763 ]]764 function chdku.deletefiles(dir,match)765 local files,err=chdku.listdir(dir,{stat="*",match=match})766 if not files then767 return false, err768 end769 -- TODO we should fix up the path properly like CLI does770 if dir ~= 'A/' then771 dir = dir .. '/'772 end773 for i,st in ipairs(files) do774 if st.is_file then775 local status,err=chdku.execwait("return os.remove('"..dir..st.name.."')")776 if not status then777 return false,err778 end779 -- print('del '..st.name)780 end781 end782 return true783 end784 780 return chdku -
trunk/lua/cli.lua
r53 r55 361 361 func=function(self,args) 362 362 local src,args = cli:get_string_arg(args) 363 if not src then 364 return false, "missing source" 365 end 363 366 local dst = cli:get_string_arg(args) 364 367 -- no dst, use filename of source … … 387 390 func=function(self,args) 388 391 local src,args = cli:get_string_arg(args) 392 if not src then 393 return false, "missing source" 394 end 389 395 local dst = cli:get_string_arg(args) 390 396 -- use final component … … 392 398 dst = util.basename(src) 393 399 -- trailing slash, append filename of source 400 -- TODO should use stat to figure out if target is a directory 394 401 elseif string.find(dst,'[\\/]$') then 395 402 dst = dst .. util.basename(src) 396 403 end 397 if not (src and dst)then404 if not dst then 398 405 return false, "bad/missing args ?" 399 406 end -
trunk/lua/util.lua
r35 r55 234 234 ]] 235 235 function util.basename(path,sfx) 236 if not path then 237 return nil 238 end 236 239 local s,e,bn=string.find(path,'([^\\/]+)[\\/]?$') 237 240 if not s then
Note: See TracChangeset
for help on using the changeset viewer.