i trying use scandir function scan root directory using lua. if use below code other directory works well. scans directory , returns files present.
directory="//home//" function scandir(directory) local i, t, popen = 0, {}, io.popen filename in popen('ls -a "'..directory..'"'):lines() = + 1 t[i] = filename--loop populates array scanned files end print(unpack(t)) return t--t contains scanned files end scandir(directory) i have few files under
user@user:~/.program$ ls file1 file2 how set path in directory such scans root dir access file1 , file2??
you don't escape forward slash / in strings. scan /home, use:
directory = "/home" the root directly represented single slash:
directory = "/"
Comments
Post a Comment