QFileSystemEngine::id/Windows: Fix use with directories
The Microsoft documentation says that CreateFile cannot be used to create directories, so you can only use it on a directory with OPEN_EXISTING and FILE_FLAG_BACKUP_SEMANTICS. This commit implements that. Change-Id: I658f552684924f8aa2cafffd14cfc0e5660a4a62 Reviewed-by: Friedemann Kleint <Friedemann.Kleint@qt.io> Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
This commit is contained in:
parent
f9afae9e08
commit
b28b3af385
@ -612,13 +612,20 @@ QByteArray fileIdWin8(HANDLE handle)
|
||||
QByteArray QFileSystemEngine::id(const QFileSystemEntry &entry)
|
||||
{
|
||||
QByteArray result;
|
||||
const HANDLE handle =
|
||||
|
||||
#ifndef Q_OS_WINRT
|
||||
const HANDLE handle =
|
||||
CreateFile((wchar_t*)entry.nativeFilePath().utf16(), 0,
|
||||
FILE_SHARE_READ, NULL, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, NULL);
|
||||
FILE_SHARE_READ, NULL, OPEN_EXISTING,
|
||||
FILE_FLAG_BACKUP_SEMANTICS, NULL);
|
||||
#else // !Q_OS_WINRT
|
||||
CREATEFILE2_EXTENDED_PARAMETERS params;
|
||||
params.dwSize = sizeof(params);
|
||||
params.dwFileAttributes = FILE_ATTRIBUTE_NORMAL;
|
||||
params.dwFileFlags = FILE_FLAG_BACKUP_SEMANTICS;
|
||||
const HANDLE handle =
|
||||
CreateFile2((const wchar_t*)entry.nativeFilePath().utf16(), 0,
|
||||
FILE_SHARE_READ, OPEN_EXISTING, NULL);
|
||||
FILE_SHARE_READ, OPEN_EXISTING, ¶ms);
|
||||
#endif // Q_OS_WINRT
|
||||
if (handle != INVALID_HANDLE_VALUE) {
|
||||
result = id(handle);
|
||||
|
Loading…
Reference in New Issue
Block a user