Created
March 6, 2018 02:14
-
-
Save jonpemby/e781d534adc690900f20158b9fc383e9 to your computer and use it in GitHub Desktop.
Lua scandir implementation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
-- Lua implementation of PHP scandir function | |
-- special thanks to: | |
-- rhoster (https://stackoverflow.com/users/974053/rhoster) | |
-- ulmangt (https://stackoverflow.com/users/1212363/ulmangt) | |
function scandir(directory) | |
local i, t, popen = 0, {}, io.popen | |
local pfile = popen('ls -a "'..directory..'"') | |
for filename in pfile:lines() do | |
i = i + 1 | |
t[i] = filename | |
end | |
pfile:close() | |
return t | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment