don't use GetFileAttributesEx() which doesn't exist in Win95 and so prevented any wx program from even starting up there; besides it was unneeded anyhow
git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@42202 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
@@ -1771,38 +1771,35 @@ int WXDLLEXPORT wxParseCommonDialogsFilter(const wxString& filterStr,
|
|||||||
}
|
}
|
||||||
|
|
||||||
#if defined( __WINDOWS__ )
|
#if defined( __WINDOWS__ )
|
||||||
bool wxCheckGenericPermission(const wxString &path, DWORD access)
|
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"
|
// CreateFile function with the FILE_FLAG_BACKUP_SEMANTICS flag", but this
|
||||||
wxWinVersion ver = wxGetWinVersion();
|
// doesn't work under Win9x/ME but then it's not needed there anyhow
|
||||||
bool isdir = wxDirExists(path);
|
bool isdir = wxDirExists(path);
|
||||||
if (isdir && (ver == wxWinVersion_95 || ver == wxWinVersion_98 || ver == wxWinVersion_ME))
|
if ( isdir && wxGetOsVersion() == wxOS_WINDOWS_9X )
|
||||||
{
|
{
|
||||||
// however Win95/98/ME do not support FILE_FLAG_BACKUP_SEMANTICS...
|
// FAT directories always allow all access, even if they have the
|
||||||
if (access == GENERIC_READ)
|
// readonly flag set
|
||||||
{
|
|
||||||
WIN32_FILE_ATTRIBUTE_DATA data;
|
|
||||||
if (GetFileAttributesEx(path.c_str(), GetFileExInfoStandard, &data) == 0)
|
|
||||||
return false; // cannot query attributes
|
|
||||||
return (data.dwFileAttributes & FILE_ATTRIBUTE_READONLY) == 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
// FIXME: is it true that directories are always writable & executable on Win9X family ?
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
else
|
|
||||||
{
|
|
||||||
HANDLE h = CreateFile(path.c_str(), access,
|
|
||||||
FILE_SHARE_READ | FILE_SHARE_WRITE | FILE_SHARE_DELETE, NULL,
|
|
||||||
OPEN_EXISTING, isdir ? FILE_FLAG_BACKUP_SEMANTICS : 0, NULL);
|
|
||||||
if (h != INVALID_HANDLE_VALUE)
|
|
||||||
CloseHandle(h);
|
|
||||||
|
|
||||||
return h != INVALID_HANDLE_VALUE;
|
HANDLE h = ::CreateFile
|
||||||
}
|
(
|
||||||
|
path.c_str(),
|
||||||
|
access,
|
||||||
|
FILE_SHARE_READ | FILE_SHARE_WRITE | FILE_SHARE_DELETE,
|
||||||
|
NULL,
|
||||||
|
OPEN_EXISTING,
|
||||||
|
isdir ? FILE_FLAG_BACKUP_SEMANTICS : 0,
|
||||||
|
NULL
|
||||||
|
);
|
||||||
|
if ( h != INVALID_HANDLE_VALUE )
|
||||||
|
CloseHandle(h);
|
||||||
|
|
||||||
|
return h != INVALID_HANDLE_VALUE;
|
||||||
}
|
}
|
||||||
#endif
|
#endif // __WINDOWS__
|
||||||
|
|
||||||
bool wxIsWritable(const wxString &path)
|
bool wxIsWritable(const wxString &path)
|
||||||
{
|
{
|
||||||
@@ -1810,7 +1807,7 @@ bool wxIsWritable(const wxString &path)
|
|||||||
// access() will take in count also symbolic links
|
// access() will take in count also symbolic links
|
||||||
return access(wxConvFile.cWX2MB(path), W_OK) == 0;
|
return access(wxConvFile.cWX2MB(path), W_OK) == 0;
|
||||||
#elif defined( __WINDOWS__ )
|
#elif defined( __WINDOWS__ )
|
||||||
return wxCheckGenericPermission(path, GENERIC_WRITE);
|
return wxCheckWin32Permission(path, GENERIC_WRITE);
|
||||||
#else
|
#else
|
||||||
wxUnusedVar(path);
|
wxUnusedVar(path);
|
||||||
// TODO
|
// TODO
|
||||||
@@ -1824,7 +1821,7 @@ bool wxIsReadable(const wxString &path)
|
|||||||
// access() will take in count also symbolic links
|
// access() will take in count also symbolic links
|
||||||
return access(wxConvFile.cWX2MB(path), R_OK) == 0;
|
return access(wxConvFile.cWX2MB(path), R_OK) == 0;
|
||||||
#elif defined( __WINDOWS__ )
|
#elif defined( __WINDOWS__ )
|
||||||
return wxCheckGenericPermission(path, GENERIC_READ);
|
return wxCheckWin32Permission(path, GENERIC_READ);
|
||||||
#else
|
#else
|
||||||
wxUnusedVar(path);
|
wxUnusedVar(path);
|
||||||
// TODO
|
// TODO
|
||||||
@@ -1838,7 +1835,7 @@ bool wxIsExecutable(const wxString &path)
|
|||||||
// access() will take in count also symbolic links
|
// access() will take in count also symbolic links
|
||||||
return access(wxConvFile.cWX2MB(path), X_OK) == 0;
|
return access(wxConvFile.cWX2MB(path), X_OK) == 0;
|
||||||
#elif defined( __WINDOWS__ )
|
#elif defined( __WINDOWS__ )
|
||||||
return wxCheckGenericPermission(path, GENERIC_EXECUTE);
|
return wxCheckWin32Permission(path, GENERIC_EXECUTE);
|
||||||
#else
|
#else
|
||||||
wxUnusedVar(path);
|
wxUnusedVar(path);
|
||||||
// TODO
|
// TODO
|
||||||
|
Reference in New Issue
Block a user