[fpc-devel] TDirectory.Delete(SomePath, True) possibly silenty deletes the contents of symlinks/junctions
Bart
bartjunk64 at gmail.com
Sun Sep 13 14:00:43 CEST 2026
Hi,
On Lazarus there has been a bugreport that DeleteDirectory follows
symlinks and unexpectedly removes their contents instead of just
deleting the symlink (or junction).
See: https://gitlab.com/freepascal.org/lazarus/lazarus/-/work_items/42561
I noticed that the DeleteDirectory() function in System.IOUtils
follows the same codepath, so this will probably happen as well.
(I did not specifically test this though).
It also may very well be that this is exactly what Delphi does, but
IMO that would be just horrible then..
(I cannot test this, since the latest Delphi I own is D7 PE, and I'm
unwilling to install their community edition, I'ld rathe keep my
laptop sort of clean)
Secondly I also noticed that Delphi says it raises an exception if the
directory does not exist, but I think fpc does not :
- the result of RemoveDir or DeleteDirectory is not checked
- the result of DeleteDirecory is True if call it on a non-existing
path with OnlyChildren=True (since in that case FindFirst will not
return 0, and there will be no consecutive call to
RemoveDir(NonExistingPath)
Should I file a bugreport for those issues?
--
Bart
More information about the fpc-devel
mailing list