readlink() proposal
there is no 'readlink()' facility in luafilesystem. just having attributes() and symlinkattributes() is cumbersome to use.
I'd like to propose following ideas, and if accepted i can implement them and send a patch:
- just implement lfs.readlink(name[, recursive]) which returns the file pointed too or 'nil' when not a symlink. If recursive is true or a number then resolve the link recursively (for n times or until reaching a final file, checking that there is no loop)
- extend the lfs.attributes() function returning a .link field when the given filename was a link. This can be a array of recursive link expansions or just the final name to which it resolves. in case of a loop, stat() already fails.
readlink() functionality was implemented as part of #78 (for non-Windows platforms). With an up-to-date LuaFileSystem you can access the symlink target via the new target attribute of symlinkattributes(), e.g.
lua -llfs -e 'print(lfs.symlinkattributes("/proc/self/exe", "target"))'
Regards, NiteHawk
Side note: The documentation is still not mentioning the "target" attribute, as the relevant change to doc/us/manual.html has not been forwarded to the gh-pages branch yet.
gh-pages is supposed to document latest release, not master
Ah, I see - good point.