Hi Taco, when writing scripts in texlua, I often have to find out whether a file or directory is readable or writable. The permission flags I get from lfs.attributes() are not sufficient. Though I can determine the UID and GID of the file owner, I still have to find out my own UID and GID and whether I'm member of a particular group. This is difficult, sometimes impossible (without access to getpwent(3) and getgrent(3)), and quite system dependent. In order to test whether a file is readable I currently open this file in a protected call. This is also possible for directories when I run lfs.dir() inside pcall(). It's not very elegant, and I still have no idea how to test whether a file is writable. I could try to open the file in append mode, but I fear that if the file is writable, this test would change the time stamps. Not very elegant either. I'm not aware of a better solution, but maybe I'm missing something. If not, I propose a new function lfs.access() which takes a file name and a string as an argument containing any combination of the letters 'r', 'w', or 'x' and returns the result of the system call access(2) (as a boolean). For instance, lfs.access(somefile, "rx") would then return the result of the system call access(somefile, R_OK|X_OK). On Windows there is a function _access() in the runtime lib which is similar to access(2) on Unix, though the executable flag isn't supported. Maybe it can be ignored. On the other hand it would be very convenient if the function returns true if the file is in PATH and its extension is in PATHEXT (as described in the MSVCRT sources). This makes the function call more expensive, but I think that access(2) is relatively expensive on Unix too because of the UID/GID lookups. I first considered to propose to extend lfs.isfile() and lfs.isdir() by an optional argument, but because lfs.isfile() checks whether a file is a regular file (which is fine), this seems to impose an unnecessary limitation: print(lfs.isfile('/dev/null')) => false print(lfs.attributes('/dev/null', 'mode')) => char device Hence, I think that a separate function lfs.access() makes more sense. WDYT? Regards, Reinhard -- ---------------------------------------------------------------------------- Reinhard Kotucha Phone: +49-511-3373112 Marschnerstr. 25 D-30167 Hannover mailto:reinhard.kotucha@web.de ---------------------------------------------------------------------------- Microsoft isn't the answer. Microsoft is the question, and the answer is NO. ----------------------------------------------------------------------------