[Date Prev][Date Next][Thread Prev][Thread Next]
- Subject: Re: [ANN] LuaFileSystem 1.2.1 Released (Andre Carregal)
- From: Peter Odding <xolox@...>
- Date: Tue, 22 May 2007 21:39:51 +0200
I would be most grateful if the standard distro could be updated (I'd
call it fixed, as you can consider this a bug IMO :-) so that the mode
field returned by lfs.attributes() is a table of strings, not just a
single string. (For backward compatibility, perhaps another field could
be added to the table for this additional data.)
In particular, this makes lfs.dir() impossible [?] to use safely for
recursively scanning a directory tree -- you can't implement an option
not to follow symlinked subtrees because you can't identify them...
Though I've never used lfs myself, reading the docs seems to indicate you are
right. That is, I don't see any way for the user to specify whether symlinks
should be followed or not. This is the way most libraries deal with this; they
either provide stat() aswell as lstat() or they make stat() accept an optional
argument to signal the difference. You're also correct that this is a problem;
it's now impossible to implement rm -rf while avoiding cycles.
Sam Roberts wrote:
But its impossible for more than one of the above modes to match!
Correct. The symlink is either followed or not. Which is what I described above.
Assuming `cycles' are considered a problem, I see several options for lfs:
* have lfs.attributes() accept an optional argument not to follow links, which
is backwards compatible, assuming no redundant arguments are passed;
* add a function which doesn't follow links;
* perform stat() aswell as lstat() in lfs.attributes(), which means both modes
can be returned.
- Peter Odding