Add support for symlinks to wxFileName.

Allow to work with the symlinks themselves and not the file they reference by
calling the new wxFileName::DontFollowLink().

Update Unix wxDir implementation to not treat symlinks to directories as
directories, this ensures that we don't recurse into the directories outside
of the original parent accidentally.

Closes #14542.

git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@72680 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
Vadim Zeitlin
2012-10-15 01:09:01 +00:00
parent 76cfd1bf95
commit c063adebba
6 changed files with 268 additions and 15 deletions

View File

@@ -485,6 +485,27 @@ public:
wxPathFormat format = wxPATH_NATIVE);
/**
Turns off symlink dereferencing.
By default, all operations in this class work on the target of a
symbolic link (symlink) if the path of the file is actually a symlink.
Using this method allows to turn off this "symlink following" behaviour
and apply the operations to this path itself, even if it is a symlink.
The following methods are currently affected by this option:
- GetTimes() (but not SetTimes() as there is no portable way to
change the time of symlink itself).
- Existence checks: FileExists(), DirExists() and Exists() (notice
that static versions of these methods always follow symlinks).
- IsSameAs().
@see ShouldFollowLink()
@since 2.9.5
*/
void DontFollowLink();
/**
Calls the static overload of this function with the full path of this
object.
@@ -1206,6 +1227,17 @@ public:
*/
void SetVolume(const wxString& volume);
/**
Return whether some operations will follow symlink.
By default, file operations "follow symlink", i.e. operate on its
target and not on the symlink itself. See DontFollowLink() for more
information.
@since 2.9.5
*/
bool ShouldFollowLink() const;
//@{
/**
This function splits a full file name into components: the volume (with the