[KERNEL32]

Rewrite GetFileAttributesW() to make it simpler and more accurate.
Make GetFileAttributesA() call GetFileAttributesW()
This fixes the last failing tests from r75236.

CORE-13495

svn path=/trunk/; revision=75915
This commit is contained in:
Pierre Schweitzer 2017-09-20 16:38:48 +00:00
parent 2a7d12c9c0
commit 31316a72ad

View file

@ -765,33 +765,55 @@ GetFileAttributesExA(LPCSTR lpFileName,
DWORD WINAPI DWORD WINAPI
GetFileAttributesA(LPCSTR lpFileName) GetFileAttributesA(LPCSTR lpFileName)
{ {
WIN32_FILE_ATTRIBUTE_DATA FileAttributeData;
PWSTR FileNameW; PWSTR FileNameW;
BOOL ret;
if (!lpFileName || !(FileNameW = FilenameA2W(lpFileName, FALSE))) if (!lpFileName || !(FileNameW = FilenameA2W(lpFileName, FALSE)))
return INVALID_FILE_ATTRIBUTES; return INVALID_FILE_ATTRIBUTES;
ret = GetFileAttributesExW(FileNameW, GetFileExInfoStandard, &FileAttributeData); return GetFileAttributesW(FileNameW);
return ret ? FileAttributeData.dwFileAttributes : INVALID_FILE_ATTRIBUTES;
} }
/* /*
* @implemented * @implemented
*/ */
DWORD WINAPI DWORD
WINAPI
GetFileAttributesW(LPCWSTR lpFileName) GetFileAttributesW(LPCWSTR lpFileName)
{ {
WIN32_FILE_ATTRIBUTE_DATA FileAttributeData; NTSTATUS Status;
BOOL Result; UNICODE_STRING FileName;
OBJECT_ATTRIBUTES ObjectAttributes;
FILE_BASIC_INFORMATION FileInformation;
TRACE ("GetFileAttributeW(%S) called\n", lpFileName); /* Get the NT path name */
if (!RtlDosPathNameToNtPathName_U(lpFileName, &FileName, NULL, NULL))
{
SetLastError(ERROR_PATH_NOT_FOUND);
return INVALID_FILE_ATTRIBUTES;
}
Result = GetFileAttributesExW(lpFileName, GetFileExInfoStandard, &FileAttributeData); /* Prepare for querying attributes */
InitializeObjectAttributes(&ObjectAttributes, &FileName,
OBJ_CASE_INSENSITIVE,
NULL, NULL);
/* Simply query attributes */
Status = NtQueryAttributesFile(&ObjectAttributes, &FileInformation);
if (!NT_SUCCESS(Status))
{
/* It failed? Is it a DOS device? */
if (RtlIsDosDeviceName_U(lpFileName))
{
return FILE_ATTRIBUTE_ARCHIVE;
}
return Result ? FileAttributeData.dwFileAttributes : INVALID_FILE_ATTRIBUTES; /* Set the error otherwise */
BaseSetLastNTError(Status);
return INVALID_FILE_ATTRIBUTES;
}
/* Return the file attributes */
return FileInformation.FileAttributes;
} }