Make wxFILE_EXISTS_SYMLINK work on its own, without wxFILE_EXISTS_NO_FOLLOW.

Include the wxFILE_EXISTS_NO_FOLLOW bit in wxFILE_EXISTS_SYMLINK definition to
allow using just wxFileName::Exists(wxFILE_EXISTS_SYMLINK) which used to never
work because the link was followed.

Closes #14777.

git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@72777 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
Vadim Zeitlin
2012-10-25 22:30:43 +00:00
parent df27f1dc9e
commit 58263bb4c3
4 changed files with 28 additions and 17 deletions

View File

@@ -737,7 +737,12 @@ wxFileSystemObjectExists(const wxString& path, int flags)
if ( S_ISDIR(st.st_mode) )
return acceptDir;
if ( S_ISLNK(st.st_mode) )
return (flags & wxFILE_EXISTS_SYMLINK) != 0;
{
// Take care to not test for "!= 0" here as this would erroneously
// return true if only wxFILE_EXISTS_NO_FOLLOW, which is part of
// wxFILE_EXISTS_SYMLINK, is set too.
return (flags & wxFILE_EXISTS_SYMLINK) == wxFILE_EXISTS_SYMLINK;
}
if ( S_ISBLK(st.st_mode) || S_ISCHR(st.st_mode) )
return (flags & wxFILE_EXISTS_DEVICE) != 0;
if ( S_ISFIFO(st.st_mode) )
@@ -1422,8 +1427,7 @@ bool wxFileName::Rmdir(const wxString& dir, int flags)
// this directory itself even when it is a symlink -- but without
// following it. Do it here as wxRmdir() would simply follow if
// called for a symlink.
if ( wxFileName::Exists(dir, wxFILE_EXISTS_SYMLINK |
wxFILE_EXISTS_NO_FOLLOW) )
if ( wxFileName::Exists(dir, wxFILE_EXISTS_SYMLINK) )
{
return wxRemoveFile(dir);
}