lua-users home
lua-l archive

[Date Prev][Date Next][Thread Prev][Thread Next] [Date Index] [Thread Index]


Andre Carregal wrote:
[...]
If you were in Windows, that would be all the information available,
but if you were in Unix you could then call lfs.symlinkattributes()
for more details.

Unfortunately, that's not the case.

In the *vast* majority of cases on Unix, when you stat a symlink, you're really interested in the thing being pointed at, not the pointer itself. That's why Unix's standard stat() syscall automatically dereferences symlinks. If you want to look at the link itself, you need to use the special lstat() syscall.

(In Prime Mover, which is based on Lua 5.0 and the Posix Lua library, there was a bug where posix.stat() actually called lstat(). This caused all sort of nasty (and difficult to track down...) behaviour, since Prime Mover uses symlinks internally to store state.)

(And you're allowed to have symlinks pointing at symlinks, so just adding a field for this-file-is-on-the-other-end-of-a-symlink doesn't work either, I'm afraid.)

--
David Given
dg@cowlark.com