implemented SetFileAttributesByHandle() and GetFileAttributesByHandle()
authorThomas Bluemel <thomas@reactsoft.com>
Wed, 24 Aug 2005 23:59:03 +0000 (23:59 +0000)
committerThomas Bluemel <thomas@reactsoft.com>
Wed, 24 Aug 2005 23:59:03 +0000 (23:59 +0000)
svn path=/trunk/; revision=17530

reactos/lib/kernel32/file/file.c
reactos/lib/kernel32/kernel32.def

index ea5f1c3..fb31b65 100644 (file)
@@ -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,
index bdaabdc..5dbcdd7 100644 (file)
@@ -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