Author: pschweitzer
Date: Wed Sep 20 16:38:48 2017
New Revision: 75915
URL:
http://svn.reactos.org/svn/reactos?rev=75915&view=rev
Log:
[KERNEL32]
Rewrite GetFileAttributesW() to make it simpler and more accurate.
Make GetFileAttributesA() call GetFileAttributesW()
This fixes the last failing tests from r75236.
CORE-13495
Modified:
trunk/reactos/dll/win32/kernel32/client/file/fileinfo.c
Modified: trunk/reactos/dll/win32/kernel32/client/file/fileinfo.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/dll/win32/kernel32/client/…
==============================================================================
--- trunk/reactos/dll/win32/kernel32/client/file/fileinfo.c [iso-8859-1] (original)
+++ trunk/reactos/dll/win32/kernel32/client/file/fileinfo.c [iso-8859-1] Wed Sep 20
16:38:48 2017
@@ -765,33 +765,55 @@
DWORD WINAPI
GetFileAttributesA(LPCSTR lpFileName)
{
- WIN32_FILE_ATTRIBUTE_DATA FileAttributeData;
PWSTR FileNameW;
- BOOL ret;
if (!lpFileName || !(FileNameW = FilenameA2W(lpFileName, FALSE)))
return INVALID_FILE_ATTRIBUTES;
- ret = GetFileAttributesExW(FileNameW, GetFileExInfoStandard, &FileAttributeData);
-
- return ret ? FileAttributeData.dwFileAttributes : INVALID_FILE_ATTRIBUTES;
-}
-
-
-/*
- * @implemented
- */
-DWORD WINAPI
+ return GetFileAttributesW(FileNameW);
+}
+
+
+/*
+ * @implemented
+ */
+DWORD
+WINAPI
GetFileAttributesW(LPCWSTR lpFileName)
{
- WIN32_FILE_ATTRIBUTE_DATA FileAttributeData;
- BOOL Result;
-
- TRACE ("GetFileAttributeW(%S) called\n", lpFileName);
-
- Result = GetFileAttributesExW(lpFileName, GetFileExInfoStandard,
&FileAttributeData);
-
- return Result ? FileAttributeData.dwFileAttributes : INVALID_FILE_ATTRIBUTES;
+ NTSTATUS Status;
+ UNICODE_STRING FileName;
+ OBJECT_ATTRIBUTES ObjectAttributes;
+ FILE_BASIC_INFORMATION FileInformation;
+
+ /* Get the NT path name */
+ if (!RtlDosPathNameToNtPathName_U(lpFileName, &FileName, NULL, NULL))
+ {
+ SetLastError(ERROR_PATH_NOT_FOUND);
+ return INVALID_FILE_ATTRIBUTES;
+ }
+
+ /* 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;
+ }
+
+ /* Set the error otherwise */
+ BaseSetLastNTError(Status);
+ return INVALID_FILE_ATTRIBUTES;
+ }
+
+ /* Return the file attributes */
+ return FileInformation.FileAttributes;
}