From: Thomas Bluemel Date: Wed, 24 Aug 2005 23:59:03 +0000 (+0000) Subject: implemented SetFileAttributesByHandle() and GetFileAttributesByHandle() X-Git-Tag: ReactOS-0.2.8~875 X-Git-Url: https://git.reactos.org/?p=reactos.git;a=commitdiff_plain;h=5760f0496c1a168f268e3798506f3d147d3954d6 implemented SetFileAttributesByHandle() and GetFileAttributesByHandle() svn path=/trunk/; revision=17530 --- diff --git a/reactos/lib/kernel32/file/file.c b/reactos/lib/kernel32/file/file.c index ea5f1c3ae4b..fb31b65e48e 100644 --- a/reactos/lib/kernel32/file/file.c +++ b/reactos/lib/kernel32/file/file.c @@ -964,6 +964,80 @@ GetFileAttributesW(LPCWSTR lpFileName) return Result ? FileAttributeData.dwFileAttributes : INVALID_FILE_ATTRIBUTES; } + +/* + * @implemented + */ +BOOL STDCALL +GetFileAttributesByHandle(IN HANDLE hFile, + OUT LPDWORD dwFileAttributes, + IN DWORD dwFlags) +{ + FILE_BASIC_INFORMATION FileBasic; + IO_STATUS_BLOCK IoStatusBlock; + NTSTATUS Status; + + UNREFERENCED_PARAMETER(dwFlags); + + Status = NtQueryInformationFile(hFile, + &IoStatusBlock, + &FileBasic, + sizeof(FileBasic), + FileBasicInformation); + if (NT_SUCCESS(Status)) + { + *dwFileAttributes = FileBasic.FileAttributes; + return TRUE; + } + + SetLastErrorByStatus(Status); + return FALSE; +} + + +/* + * @implemented + */ +BOOL STDCALL +SetFileAttributesByHandle(IN HANDLE hFile, + IN DWORD dwFileAttributes, + IN DWORD dwFlags) +{ + FILE_BASIC_INFORMATION FileBasic; + IO_STATUS_BLOCK IoStatusBlock; + NTSTATUS Status; + + UNREFERENCED_PARAMETER(dwFlags); + + Status = NtQueryInformationFile(hFile, + &IoStatusBlock, + &FileBasic, + sizeof(FileBasic), + FileBasicInformation); + if (NT_SUCCESS(Status)) + { + FileBasic.FileAttributes = dwFileAttributes; + + Status = NtSetInformationFile(hFile, + &IoStatusBlock, + &FileBasic, + sizeof(FileBasic), + FileBasicInformation); + } + + if (!NT_SUCCESS(Status)) + { + SetLastErrorByStatus(Status); + return FALSE; + } + + return TRUE; +} + + +/* + * @implemented + */ BOOL STDCALL SetFileAttributesA( LPCSTR lpFileName, diff --git a/reactos/lib/kernel32/kernel32.def b/reactos/lib/kernel32/kernel32.def index bdaabdc7f55..5dbcdd7b675 100644 --- a/reactos/lib/kernel32/kernel32.def +++ b/reactos/lib/kernel32/kernel32.def @@ -372,6 +372,7 @@ GetExpandedNameA@8 GetExpandedNameW@8 GetFileAttributesA@4 GetFileAttributesW@4 +GetFileAttributesByHandle@12 GetFileAttributesExA@12 GetFileAttributesExW@12 GetFileInformationByHandle@8 @@ -805,6 +806,7 @@ SetFileApisToANSI@0 SetFileApisToOEM@0 SetFileAttributesA@8 SetFileAttributesW@8 +SetFileAttributesByHandle@12 SetFilePointer@16 SetFilePointerEx@20 SetFileShortNameA@8