-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtools.lua
67 lines (61 loc) · 1.39 KB
/
tools.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
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
---
--- Generated by EmmyLua(https://github.com/EmmyLua)
--- Created by wakfu.
--- DateTime: 2020/6/9 10:58
---
local tools = { _version = "1.0" }
--*******************************工具栏*******************************
---文件是否存在
---@param path string 文件名
function tools.file_exists(path)
local file = io.open(path, "r")
if file then
file:close()
end
return file ~= nil
end
-- trim
---@param str string
----@return string
function tools.trimAll(str)
if type(str) == "number" then
return false
end
return str:gsub("^%s*(.-)%s*$", "%1")
end
-- 查询是否为空字符
---@param str string
----@return boolean
function tools.isStrEmpty(str)
if str then
--前后trim空格
local strNew = trimAll(str)
if strNew == "" or strNew == "''" then
return true
end
return false
else
return true
end
end
--是否是ip地址
---@param ipStr string
---@return boolean 是否是ip地址
function tools.isIP(ipStr)
if type(ipStr) == 'string' then
local ips = { ipStr:find("^(%d+)%.(%d+)%.(%d+)%.(%d+)$") }
if #ips > 0 then
return true
end
return false
else
return false
end
end
--显示所有的
function tools.showLoadedPackage()
for key, _ in pairs(package.loaded) do
print("loaded", tostring(key))
end
end
return tools