change to basic file info on WinRT

FILE_FULL_DIR_INFO failed under certain circumstances on WinRT and
provides far more information than required. Hence prefer the basic
version in every case and standard for files with size description.

Change-Id: I63f1365f83cdd5d69f81278411f822dbd361fa92
Reviewed-by: Oliver Wolff <oliver.wolff@digia.com>
This commit is contained in:
Maurice Kalinowski 2013-11-12 09:54:53 +01:00 committed by The Qt Project
parent 0de8370531
commit f7f9126ed7

View File

@ -956,17 +956,22 @@ bool QFileSystemEngine::fillMetaData(HANDLE fHandle, QFileSystemMetaData &data,
}
SetErrorMode(oldmode);
#else // !Q_OS_WINRT
FILE_FULL_DIR_INFO fileInfo;
if (GetFileInformationByHandleEx(fHandle, FileFullDirectoryInfo, &fileInfo, sizeof(fileInfo))) {
data.fillFromFileAttribute(fileInfo.FileAttributes);
data.creationTime_.dwHighDateTime = fileInfo.CreationTime.HighPart;
data.creationTime_.dwLowDateTime = fileInfo.CreationTime.LowPart;
data.lastAccessTime_.dwHighDateTime = fileInfo.LastAccessTime.HighPart;
data.lastAccessTime_.dwLowDateTime = fileInfo.LastAccessTime.LowPart;
data.lastWriteTime_.dwHighDateTime = fileInfo.LastWriteTime.HighPart;
data.lastWriteTime_.dwLowDateTime = fileInfo.LastWriteTime.LowPart;
data.fileAttribute_ & FILE_ATTRIBUTE_DIRECTORY ? data.size_ = 0 : data.size_ = fileInfo.AllocationSize.QuadPart;
data.knownFlagsMask |= data.Times | data.SizeAttribute;
FILE_BASIC_INFO fileBasicInfo;
if (GetFileInformationByHandleEx(fHandle, FileBasicInfo, &fileBasicInfo, sizeof(fileBasicInfo))) {
data.fillFromFileAttribute(fileBasicInfo.FileAttributes);
data.creationTime_.dwHighDateTime = fileBasicInfo.CreationTime.HighPart;
data.creationTime_.dwLowDateTime = fileBasicInfo.CreationTime.LowPart;
data.lastAccessTime_.dwHighDateTime = fileBasicInfo.LastAccessTime.HighPart;
data.lastAccessTime_.dwLowDateTime = fileBasicInfo.LastAccessTime.LowPart;
data.lastWriteTime_.dwHighDateTime = fileBasicInfo.LastWriteTime.HighPart;
data.lastWriteTime_.dwLowDateTime = fileBasicInfo.LastWriteTime.LowPart;
if (!(data.fileAttribute_ & FILE_ATTRIBUTE_DIRECTORY)) {
FILE_STANDARD_INFO fileStandardInfo;
if (GetFileInformationByHandleEx(fHandle, FileStandardInfo, &fileStandardInfo, sizeof(fileStandardInfo)))
data.size_ = fileStandardInfo.EndOfFile.QuadPart;
} else
data.size_ = 0;
data.knownFlagsMask |= QFileSystemMetaData::Times | QFileSystemMetaData::SizeAttribute;
}
#endif // Q_OS_WINRT
return data.hasFlags(what);