5.4 Lua primer 107
r, msg, no = os.mkdir(dirname)
creates a new directory with a specified path name such as “A:/CHDK/
WORK”. Please note that the path name must not end with a slash. If the
function succeeds, true is returned. If it fails, nil is returned, followed by
an error message and an error number.
t, msg, no = os.stat(filename)
delivers a table t containing information about the specified file.
Key Value
dev Device number
mode Meaning unclear
size Size in bytes
atime Last access time
mtime Last modification
ctime Last status change
blksize Block size in bytes
blocks Number of blocks in the file
attrib Bit mask of DOS attributes
is_dir true for a directory
is_file true for a file
If the function fails, nil is returned, followed by an error message and an
error number.
r, msg, no =
os.utime(filename,atime,mtime)
sets the time of last access and the time of last modification for the speci-
fied file. If atime or mtime is omitted or nil, the current time is used. If the
function succeeds, true is returned. If it fails, nil is returned, followed by
an error message and an error number.
t, msg, no =
os.listdir(dirpath,showall)