-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathHfSr_file_lib.lua
46 lines (44 loc) · 988 Bytes
/
HfSr_file_lib.lua
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
local os=require("os")
function find_table(tab,key,val)
for i,v in pairs(tab) do
if i==key and val==nil then
return tab[i]
end
if key==nil and v==val then
return i
end
if i==key and v==val then
return true
end
end
return false
end
function file_exist(path)
local file = io.open(path, "rb")
if file then file:close() end
return file ~= nil
end
function path_exist(path)
return os.execute("cd ".."\""..path.."\" 1>/dev/null 2>/dev/null")
end
function new_path(path)
os.execute("mkdir "..path)
end
function auto_clean_file(file,max_size,del)
if del==nil then
del=false
end
local del_f=io.open(file,'r')
if del_f:seek("end")>max_size then
if del then
os.execute("rm".."\""..file.."\" 1>/dev/null 2>/dev/null")
else
del_f=io.open(file,'w')
end
del_f:close()
return true
else
del_f:close()
return false
end
end