add filename extraction
This commit is contained in:
parent
d30a0e462b
commit
e706a75645
|
|
@ -106,7 +106,23 @@ function path.Walk_Up( P )
|
|||
return string.sub(P, 1, #P - slash_first_idx + 1)
|
||||
end
|
||||
|
||||
function path.Get_File( P )
|
||||
local rev = string.reverse(P)
|
||||
local start = 1
|
||||
|
||||
local slash_first_idx, _ = string.find(rev, "/", start, true)
|
||||
|
||||
return string.sub(P, #P - slash_first_idx + 2)
|
||||
end
|
||||
|
||||
function path.Get_Filename( File )
|
||||
local dot_first_idx, _ = string.find(File, ".", 1, true)
|
||||
|
||||
return string.sub(File, 1, dot_first_idx - 1)
|
||||
end
|
||||
|
||||
function path.Generate_Dir_Walk( Base, Descend_List )
|
||||
Descend_List = Descend_List or {}
|
||||
local Descend_Length = #Descend_List
|
||||
|
||||
local i = -1
|
||||
|
|
@ -123,18 +139,11 @@ function path.Generate_Dir_Walk( Base, Descend_List )
|
|||
if i == 0 then
|
||||
return Base_Dir
|
||||
elseif i <= Descend_Length then
|
||||
return Base_Dir .. Descend_List[i]
|
||||
return Base_Dir .. Descend_List[i] .. "/"
|
||||
end
|
||||
end
|
||||
|
||||
return Inner
|
||||
end
|
||||
|
||||
print(path.Common_Root("/home/folkert/Documents/Projects","/home/folkert/Downloads/sub/sub2/sub3/sub4/hello.txt"))
|
||||
print(path.Get_Ext("/home/folkert/Documents/projects.wo.cp", {"o.cp"}))
|
||||
|
||||
for x in path.Generate_Dir_Walk("/home/folkert/", {"include", "src"}) do
|
||||
print(x)
|
||||
end
|
||||
|
||||
return path
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user