Applied backport for fix to #4111: wxFileName::IsFileReadable fails under Windows 98
git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/branches/WX_2_8_BRANCH@66939 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
@@ -1831,22 +1831,32 @@ static bool wxCheckWin32Permission(const wxString& path, DWORD access)
|
|||||||
// quoting the MSDN: "To obtain a handle to a directory, call the
|
// quoting the MSDN: "To obtain a handle to a directory, call the
|
||||||
// CreateFile function with the FILE_FLAG_BACKUP_SEMANTICS flag", but this
|
// CreateFile function with the FILE_FLAG_BACKUP_SEMANTICS flag", but this
|
||||||
// doesn't work under Win9x/ME but then it's not needed there anyhow
|
// doesn't work under Win9x/ME but then it's not needed there anyhow
|
||||||
bool isdir = wxDirExists(path);
|
const DWORD dwAttr = ::GetFileAttributes(path.fn_str());
|
||||||
if ( isdir && wxGetOsVersion() == wxOS_WINDOWS_9X )
|
if ( dwAttr == INVALID_FILE_ATTRIBUTES )
|
||||||
|
{
|
||||||
|
// file probably doesn't exist at all
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
if ( wxGetOsVersion() == wxOS_WINDOWS_9X )
|
||||||
{
|
{
|
||||||
// FAT directories always allow all access, even if they have the
|
// FAT directories always allow all access, even if they have the
|
||||||
// readonly flag set
|
// readonly flag set, and FAT files can only be read-only
|
||||||
return true;
|
return (dwAttr & FILE_ATTRIBUTE_DIRECTORY) ||
|
||||||
|
(access != GENERIC_WRITE ||
|
||||||
|
!(dwAttr & FILE_ATTRIBUTE_READONLY));
|
||||||
}
|
}
|
||||||
|
|
||||||
HANDLE h = ::CreateFile
|
HANDLE h = ::CreateFile
|
||||||
(
|
(
|
||||||
path.c_str(),
|
path.t_str(),
|
||||||
access,
|
access,
|
||||||
FILE_SHARE_READ | FILE_SHARE_WRITE | FILE_SHARE_DELETE,
|
FILE_SHARE_READ | FILE_SHARE_WRITE | FILE_SHARE_DELETE,
|
||||||
NULL,
|
NULL,
|
||||||
OPEN_EXISTING,
|
OPEN_EXISTING,
|
||||||
isdir ? FILE_FLAG_BACKUP_SEMANTICS : 0,
|
dwAttr & FILE_ATTRIBUTE_DIRECTORY
|
||||||
|
? FILE_FLAG_BACKUP_SEMANTICS
|
||||||
|
: 0,
|
||||||
NULL
|
NULL
|
||||||
);
|
);
|
||||||
if ( h != INVALID_HANDLE_VALUE )
|
if ( h != INVALID_HANDLE_VALUE )
|
||||||
|
Reference in New Issue
Block a user