Added os.stat and os.utime (both not in the standard lua os library, but they fit logically there)
These work roughly the same way as the C functions of the same names.
stat takes a file name, and returns a table on success, or nil plus an error message and errno.
The table has the following fields (all numbers)
dev: device number
mode: not clear which bits are useful. it does change depending on whether you look at a file or directory (but you should use attrib or is_* below instead)
size: size in bytes
atime: time of last access
mtime: time of last modification
ctime: time of last change of file status
blksize: block size in bytes. This is NOT the dos sector size. 512 on all I've tested, possibly hardware block size.
blocks: Number of blksize blocks in the file. blocks*blocksizes is not the same as "size on disk", per above.
attrib: bitmask of dos attributes (see stdlib.h)
The following boolean values are set based on attrib, so you don't have to do bit testing for the most common values of interest:
is_dir
is_file
Note that it is possible for to stat things that are neither file nor directory, e.g. volume labels. So you should test for exactly what you want, rather than assuming that NOT is_file is a directory.
Note that for files larger than 2gb would appear to have a negative size in lua.
utime takes a file name, followed by optional numbers for mtime and atime (describe above). If either time is missing, the current time is used. It returns true on success, or nil, "error message", errno.
llibtst.lua is updated to test these functions, and is now included in the distribution directory CHDK/SCRIPTS/TEST/LLIBTST.LUA
I haven't added sujithh's tmpname. The effort is appreciated, but IMO it's probably better to do the whole thing in lua. I apologize for any wasted time.