Perhaps something simpler?
The following should give you the path in t[1] and the file names in the rest of the table:
(Except if #t == 1, in which case the entire path and filename is in t[1].)
Code:
t = {}
for file in files:gmatch("[^\0]*")
t[#t+1] = file
end