Ticket #14542 (closed defect: fixed)
Make wxFileName and wxDir symlink-friendly
|Reported by:||dghart||Owned by:|
|Keywords:||wxFileName wxDir symlink||Cc:|
|Blocking:||1993, 1993, 1993, 1993, 14649, 14649, 14649, 14649, 14649, 14649, 14649, 14649, 14649, 14649|
This patch was prompted by trying to use wxFileSystemWatcher to watch a directory that contained a symlink to another directory in the same tree. wxDir::Traverse always follows symlinks, so the destination dir was added multiple times, the symlink not at all.
The main patch does the following:
wxFileName: As suggested on wx-dev, there are two new functions, DontFollowLink() and ShouldFollowLink(). I've also added a dereferenceLink parameter to the static versions of FileExists(), DirExists() and Exists(), the current behaviour being the default. These changes are documented.
wxDir: The only alteration needed was to wxDirData::Read in src/unix/dir.cpp, which now uses wxFileName::DirExists with the new dereferenceLink parameter false. I've not made deferencing optional as I doubt if anyone would ever want to; but it could be added if you wish.
This fix also makes wxFileName::Rmdir(wxPATH_RMDIR_RECURSIVE) succeed when the directory contains a symlink-to-directory; previously the symlink wasn't removed, so the final wxRmdir() failed.
The other patch adds a section testing this to the 'filename' unit test.