Posted 24 March 2016 - 04:34 PM
I am making an apis file to later share, but this function I made keeps returning an empty table.
--apis--
tPath = function( sFile )
if string.sub( sFile, 0, 1) == '/' then
sFile = ':' .. sFile
end
if string.sub(sFile, 0, 2) ~= ':/' then
sFile = ':/' .. sFile
end
if string.sub(sFile, #sFile- 1, #sFile) ~= '/' then
sFile = sFile .. '/'
end
local lastSlash = 0
local folder = {}
i=0
while i ~= #sFile do
if string.sub(sFile, i, i+1)=='/' then
table.insert(folder, string.sub(sFile, lastSlash, i+1))
lastSlash = i
end
i=i+1
end
return folder
end
--test file--
os.loadAPI('apis')
args = {...}
for n, string in ipairs( apis.tPath(args[1])) do
print(string)
end
--command--
test main/test/somepath