FindFirst does not set faSymlink in Attribute on symlinks
Original Reporter info from Mantis: Bart @flyingsheep
-
Reporter name: Bart Broersma
Original Reporter info from Mantis: Bart @flyingsheep
- Reporter name: Bart Broersma
Description:
If you use FindFirst/FindNext to travers a directory, it does not set faSymLink in TSearchRec.Attribute if the file is a symlink.
Additional information:
Ultimately it boils down to the fact that FindFirst/FindNext use FpStat() to get Stat Info on the found file. FpStat() will follow the link and thus report Stat info of the target of the symlink, not of the symlink itself.
For example a link to a regular file will have a mode of $81A4, which will translate to an attribute of $20 (faArchive).
A symlink to a regular file now gives the same mode and attribute.
This can be overcome by using FpLStat() instead. This will report Stat Info on the symlink itself.
Now the symlink to a regular file will have a mode of $A1FF, which will translate to an attribute of $0060 (faSymLink or faArchive).
That leaves the matter of Symlinks to directories: should they have faDirectory set in their attribute? This can easily be achieved, but I'm not sure if this should be done (I'm a Linux newbie and not familiar with linux customs...).
On the other hand we should give programmers that recursively travers directories the change to (1) see that there is a symlink to a directory here and (2) let them (or the user) decide if they want to follow that symlink.
PS. I know I'm not using fpc 2.2.0, but the 2.0.4 that comes with the tast stable Lazarus version. But I took a glance at the source of 2.2.0 and saw that the code foor FF/FN was heavily altered, but it still uses fpstat().
If it is desired that FF/FN set faSymlink then I can write a patch for it (but only if I can savely upgrade fpc to 2.2.0 (taht is replace the old one) and still use my current Lazarus (0.9.22).
Mantis conversion info:
- Mantis ID: 9915
- OS: Suse Linux
- OS Build: 10.0
- Platform: i386
- Version: 2.0.4
- Fixed in version: 2.2.4
- Fixed in revision: 12097 (#7a1434fa)