iter, dir_obj = lfs.dir (path)
Lua iterator over the entries of a given directory. Each time the iterator is called with dir_obj
it returns a directory entry‘s name as a string, or nil
if there are no more entries. You can also iterate by calling dir_obj:next()
, and explicitly close the directory before the iteration finished with dir_obj:close()
. Raises an error if path
is not a directory.
lfs.attributes(属性) (filepath [, aname])
Returns a table with the file attributes corresponding to filepath
(or nil
followed by an error message in case of error). If the second optional(可选择的) argument is given, then only the value of the named attribute is returned (this use is equivalent(等价的) to lfs.attributes(filepath).aname
, but the table is not created and only one attribute is retrieved(检索)from the O.S.). The attributes are described as follows; attribute mode
is a string, all the others are numbers, and the time related attributes use the same time reference(参考) ofos.time
:
dev
ino
mode
file
, directory
, link
, socket
, named pipe
, char device
, block device
or other
)nlink
uid
gid
rdev
dev
access
modification
change
size
blocks
blksize
This function uses stat
internally(内部地) thus if the given filepath
is a symbolic(象征的) link, it is followed (if it points to another link the chain is followed recursively(递归的)) and the information is about the file it refers to. To obtain information about the link itself, see function lfs.symlinkattributes.
原文:http://www.cnblogs.com/dotdog/p/4562036.html