Compare file inodes if possible in wxFileName::SameAs().

This allows to correctly return when the two files with different names
actually refer to the same file system object.

Closes #910.

git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@70687 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
Vadim Zeitlin
2012-02-25 23:49:35 +00:00
parent 41fec01fa9
commit 7c9b6c9111
2 changed files with 64 additions and 2 deletions

View File

@@ -1794,8 +1794,16 @@ bool wxFileName::SameAs(const wxFileName& filepath, wxPathFormat format) const
if ( fn1.GetFullPath() == fn2.GetFullPath() )
return true;
// TODO: compare inodes for Unix, this works even when filenames are
// different but files are the same (symlinks) (VZ)
#if defined(__UNIX__)
wxStructStat st1, st2;
if ( wxStat(fn1.GetFullPath(), &st1) == 0 &&
wxStat(fn2.GetFullPath(), &st2) == 0 )
{
if ( st1.st_ino == st2.st_ino && st1.st_dev == st2.st_dev )
return true;
}
//else: It's not an error if one or both files don't exist.
#endif // defined __UNIX__
return false;
}