1

Possible Duplicate:
Get List of Directory in a Lua

I need to list all files in a given directory using lua language. without adding "require lfs"

How to get the list of files in a directory in lua ?

Community
  • 1
  • 1
abdou
  • 39
  • 1
  • 1
  • 2

1 Answers1

4

do yourself a favor and use LuaFileSystem...

if you're on windows and want to do it the hard way, you're basically just going to be calling "dir" using io.popen() and parsing the values you get back.

local f = io.popen("dir \"C:\\users\\\"")
if f then
    print(f:read("*a"))
else
    print("failed to read")
end

that will dump everything in your C:\users directory (including . and ..). you'll then have to write a function to parse out the files/directories and form them into well formed paths.

Mike Corcoran
  • 14,072
  • 4
  • 37
  • 49