From e9f3a8740c5384d164ef6a1ff2b6131bf67b60d2 Mon Sep 17 00:00:00 2001 From: Hartmut Birr Date: Mon, 9 Jun 2003 19:58:21 +0000 Subject: [PATCH] - Implemented GetFileAttributesExA/W. svn path=/trunk/; revision=4877 --- reactos/include/ascii.h | 8 ++ reactos/include/funcs.h | 2 + reactos/include/unicode.h | 8 ++ reactos/lib/kernel32/file/file.c | 142 +++++++++++++++++++++--------- reactos/lib/kernel32/kernel32.def | 4 +- reactos/lib/kernel32/misc/stubs.c | 27 +----- 6 files changed, 122 insertions(+), 69 deletions(-) diff --git a/reactos/include/ascii.h b/reactos/include/ascii.h index 82f91ef5dd4..f239a5ac5f7 100644 --- a/reactos/include/ascii.h +++ b/reactos/include/ascii.h @@ -606,6 +606,14 @@ GetFileAttributesA( LPCSTR lpFileName ); +BOOL +STDCALL +GetFileAttributesExA( + LPCSTR lpFileName, + GET_FILEEX_INFO_LEVELS fInfoLevelId, + LPVOID lpFileInformation + ); + DWORD STDCALL GetCompressedFileSizeA( diff --git a/reactos/include/funcs.h b/reactos/include/funcs.h index f81c4e19425..1149410b286 100644 --- a/reactos/include/funcs.h +++ b/reactos/include/funcs.h @@ -347,6 +347,7 @@ typedef PPROGRESS_ROUTINE LPPROGRESS_ROUTINE; #define CreateFile CreateFileW #define SetFileAttributes SetFileAttributesW #define GetFileAttributes GetFileAttributesW +#define GetFileAttributesEx GetFileAttributesExW #define GetCompressedFileSize GetCompressedFileSizeW #define DeleteFile DeleteFileW #define FindFirstFileEx FindFirstFileExW @@ -753,6 +754,7 @@ typedef PPROGRESS_ROUTINE LPPROGRESS_ROUTINE; #define CreateFile CreateFileA #define SetFileAttributes SetFileAttributesA #define GetFileAttributes GetFileAttributesA +#define GetFileAttributesEx GetFileAttributesExA #define GetCompressedFileSize GetCompressedFileSizeA #define DeleteFile DeleteFileA #define FindFirstFileEx FindFirstFileExA diff --git a/reactos/include/unicode.h b/reactos/include/unicode.h index a37474d374f..13d9ba5b129 100644 --- a/reactos/include/unicode.h +++ b/reactos/include/unicode.h @@ -607,6 +607,14 @@ GetFileAttributesW( LPCWSTR lpFileName ); +BOOL +STDCALL +GetFileAttributesExW( + LPCWSTR lpFileName, + GET_FILEEX_INFO_LEVELS fInfoLevelId, + LPVOID lpFileInformation + ); + DWORD STDCALL GetCompressedFileSizeW( diff --git a/reactos/lib/kernel32/file/file.c b/reactos/lib/kernel32/file/file.c index fb6d9635152..28fad01b67f 100644 --- a/reactos/lib/kernel32/file/file.c +++ b/reactos/lib/kernel32/file/file.c @@ -1,4 +1,4 @@ -/* $Id: file.c,v 1.43 2003/03/23 04:01:16 ekohl Exp $ +/* $Id: file.c,v 1.44 2003/06/09 19:58:21 hbirr Exp $ * * COPYRIGHT: See COPYING in the top level directory * PROJECT: ReactOS system libraries @@ -491,46 +491,27 @@ GetFileInformationByHandle(HANDLE hFile, return TRUE; } - -DWORD STDCALL -GetFileAttributesA(LPCSTR lpFileName) +BOOL STDCALL +GetFileAttributesExW(LPCWSTR lpFileName, + GET_FILEEX_INFO_LEVELS fInfoLevelId, + LPVOID lpFileInformation) { - UNICODE_STRING FileNameU; - ANSI_STRING FileName; - WINBOOL Result; - - RtlInitAnsiString (&FileName, - (LPSTR)lpFileName); - - /* convert ansi (or oem) string to unicode */ - if (bIsFileApiAnsi) - RtlAnsiStringToUnicodeString (&FileNameU, - &FileName, - TRUE); - else - RtlOemStringToUnicodeString (&FileNameU, - &FileName, - TRUE); - - Result = GetFileAttributesW (FileNameU.Buffer); - - RtlFreeUnicodeString (&FileNameU); - - return Result; -} - - -DWORD STDCALL -GetFileAttributesW(LPCWSTR lpFileName) -{ - FILE_BASIC_INFORMATION FileInformation; + FILE_NETWORK_OPEN_INFORMATION FileInformation; OBJECT_ATTRIBUTES ObjectAttributes; IO_STATUS_BLOCK IoStatusBlock; UNICODE_STRING FileName; HANDLE FileHandle; NTSTATUS Status; + WIN32_FILE_ATTRIBUTE_DATA* FileAttributeData; - DPRINT ("GetFileAttributeW(%S) called\n", lpFileName); + DPRINT ("GetFileAttributesExW(%S) called\n", lpFileName); + + + if (fInfoLevelId != GetFileExInfoStandard || lpFileInformation == NULL) + { + SetLastError(ERROR_INVALID_PARAMETER); + return FALSE; + } /* Validate and translate the filename */ if (!RtlDosPathNameToNtPathName_U ((LPWSTR)lpFileName, @@ -540,9 +521,8 @@ GetFileAttributesW(LPCWSTR lpFileName) { DPRINT ("Invalid path\n"); SetLastError (ERROR_BAD_PATHNAME); - return 0xFFFFFFFF; + return FALSE; } - DPRINT ("FileName: \'%wZ\'\n", &FileName); /* build the object attributes */ InitializeObjectAttributes (&ObjectAttributes, @@ -563,26 +543,106 @@ GetFileAttributesW(LPCWSTR lpFileName) { DPRINT ("NtOpenFile() failed (Status %lx)\n", Status); SetLastErrorByStatus (Status); - return 0xFFFFFFFF; + return FALSE; } /* Get file attributes */ Status = NtQueryInformationFile (FileHandle, &IoStatusBlock, &FileInformation, - sizeof(FILE_BASIC_INFORMATION), - FileBasicInformation); + sizeof(FILE_NETWORK_OPEN_INFORMATION), + FileNetworkOpenInformation); NtClose (FileHandle); + if (!NT_SUCCESS (Status)) { DPRINT ("NtQueryInformationFile() failed (Status %lx)\n", Status); SetLastErrorByStatus (Status); - return 0xFFFFFFFF; + return FALSE; } - return (DWORD)FileInformation.FileAttributes; + FileAttributeData = (WIN32_FILE_ATTRIBUTE_DATA*)lpFileInformation; + FileAttributeData->dwFileAttributes = FileInformation.FileAttributes; + FileAttributeData->ftCreationTime.dwLowDateTime = FileInformation.CreationTime.u.LowPart; + FileAttributeData->ftCreationTime.dwHighDateTime = FileInformation.CreationTime.u.HighPart; + FileAttributeData->ftLastAccessTime.dwLowDateTime = FileInformation.LastAccessTime.u.LowPart; + FileAttributeData->ftLastAccessTime.dwHighDateTime = FileInformation.LastAccessTime.u.HighPart; + FileAttributeData->ftLastWriteTime.dwLowDateTime = FileInformation.LastWriteTime.u.LowPart; + FileAttributeData->ftLastWriteTime.dwHighDateTime = FileInformation.LastWriteTime.u.HighPart; + FileAttributeData->nFileSizeLow = FileInformation.EndOfFile.u.LowPart; + FileAttributeData->nFileSizeHigh = FileInformation.EndOfFile.u.HighPart; + + return TRUE; } +BOOL STDCALL +GetFileAttributesExA(LPCSTR lpFileName, + GET_FILEEX_INFO_LEVELS fInfoLevelId, + LPVOID lpFileInformation) +{ + UNICODE_STRING FileNameU; + ANSI_STRING FileName; + BOOL Result; + RtlInitAnsiString (&FileName, + (LPSTR)lpFileName); + + /* convert ansi (or oem) string to unicode */ + if (bIsFileApiAnsi) + RtlAnsiStringToUnicodeString (&FileNameU, + &FileName, + TRUE); + else + RtlOemStringToUnicodeString (&FileNameU, + &FileName, + TRUE); + + Result = GetFileAttributesExW(FileNameU.Buffer, fInfoLevelId, lpFileInformation); + + RtlFreeUnicodeString (&FileNameU); + + return Result; +} + +DWORD STDCALL +GetFileAttributesA(LPCSTR lpFileName) +{ + WIN32_FILE_ATTRIBUTE_DATA FileAttributeData; + UNICODE_STRING FileNameU; + ANSI_STRING FileName; + BOOL Result; + + RtlInitAnsiString (&FileName, + (LPSTR)lpFileName); + + /* convert ansi (or oem) string to unicode */ + if (bIsFileApiAnsi) + RtlAnsiStringToUnicodeString (&FileNameU, + &FileName, + TRUE); + else + RtlOemStringToUnicodeString (&FileNameU, + &FileName, + TRUE); + + Result = GetFileAttributesExW(FileNameU.Buffer, GetFileExInfoStandard, &FileAttributeData); + + RtlFreeUnicodeString (&FileNameU); + + return Result ? FileAttributeData.dwFileAttributes : 0xffffffff; +} + +DWORD STDCALL +GetFileAttributesW(LPCWSTR lpFileName) +{ + WIN32_FILE_ATTRIBUTE_DATA FileAttributeData; + BOOL Result; + + DPRINT ("GetFileAttributeW(%S) called\n", lpFileName); + + Result = GetFileAttributesExW(lpFileName, GetFileExInfoStandard, &FileAttributeData); + + return Result ? FileAttributeData.dwFileAttributes : 0xffffffff; +} WINBOOL STDCALL SetFileAttributesA(LPCSTR lpFileName, diff --git a/reactos/lib/kernel32/kernel32.def b/reactos/lib/kernel32/kernel32.def index 33109d7f89f..9187a90dc73 100644 --- a/reactos/lib/kernel32/kernel32.def +++ b/reactos/lib/kernel32/kernel32.def @@ -265,8 +265,8 @@ GetExitCodeProcess@8 GetExitCodeThread@8 GetFileAttributesA@4 GetFileAttributesW@4 -GetFileAttributesExA -GetFileAttributesExW +GetFileAttributesExA@12 +GetFileAttributesExW@12 GetFileInformationByHandle@8 GetFileSize@8 GetFileTime@16 diff --git a/reactos/lib/kernel32/misc/stubs.c b/reactos/lib/kernel32/misc/stubs.c index 72aa445dd5f..dd126bd01f7 100644 --- a/reactos/lib/kernel32/misc/stubs.c +++ b/reactos/lib/kernel32/misc/stubs.c @@ -1,4 +1,4 @@ -/* $Id: stubs.c,v 1.50 2003/06/08 20:59:30 ekohl Exp $ +/* $Id: stubs.c,v 1.51 2003/06/09 19:58:21 hbirr Exp $ * * KERNEL32.DLL stubs (unimplemented functions) * Remove from this file, if you implement them. @@ -945,29 +945,4 @@ VirtualBufferExceptionHandler ( } -BOOL -STDCALL -GetFileAttributesExA( - LPCSTR lpFileName, - GET_FILEEX_INFO_LEVELS fInfoLevelId, - LPVOID lpFileInformation - ) -{ - SetLastError(ERROR_CALL_NOT_IMPLEMENTED); - return 0; -} - - -BOOL -STDCALL -GetFileAttributesExW( - LPCWSTR lpFileName, - GET_FILEEX_INFO_LEVELS fInfoLevelId, - LPVOID lpFileInformation - ) -{ - SetLastError(ERROR_CALL_NOT_IMPLEMENTED); - return 0; -} - /* EOF */