1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74
|
msg_order={["--getDiceList="]="getDiceList",["--getRootList="]="getRootList"}
read_file = function(path,mode1,mode2) local text = "" local file = io.open(path,mode1) if (file ~= nil) then text = file.read(file, mode2) io.close(file) else return "没有找到文件哦~" end return text end
getLineCount = function(path) local BUFSIZE = 2^13 local f = io.input(path) local lc = 0
while true do local lines,rest = f:read(BUFSIZE,'*line') if not lines then break end if rest then lines = lines .. rest .. '\n' end local _,t = string.gsub(lines,"%S+","") _,t = string.gsub(lines,"\n","\n") lc = lc + t end
return lc end
getDiceList = function(msg) local path = string.sub(msg.fromMsg,#'--getDiceList='+1) local Dir = path if path == 'nil' then Dir = nil end if Dir then cmd = 'dir '.. getDiceDir()..'\\'..path..' /b >'..getDiceDir()..'//DiceList.txt' os.execute(cmd) else cmd = 'dir '.. getDiceDir()..' /b >'..getDiceDir()..'//DiceList.txt' os.execute(cmd) end return read_file(getDiceDir()..'//DiceList.txt','r','*a')..os.date('\n%x')..'\n文件夹与文件共 '..getLineCount(getDiceDir()..'//DiceList.txt')..' 个'
end
getRootList = function(msg) local path = string.sub(msg.fromMsg,#'--getRootList='+1) local Dir = path if path == 'nil' then Dir = nil end if Dir then cmd = 'dir '..path..' /b >'..getDiceDir()..'//RootList.txt' os.execute(cmd) else cmd = 'dir /b >'..getDiceDir()..'//RootList.txt' os.execute(cmd) end return read_file(getDiceDir()..'//RootList.txt','r','*a')..os.date('\n%x')..'\n文件夹与文件共 '..getLineCount(getDiceDir()..'//RootList.txt')..' 个'
end
|