implemented GetFinalPathNameByHandleA() and added stub for GetFinalPathNameByHandleW()
Modified: trunk/reactos/lib/kernel32/file/file.c
Modified: trunk/reactos/lib/kernel32/kernel32.def
Modified: trunk/reactos/w32api/include/winbase.h

Modified: trunk/reactos/lib/kernel32/file/file.c
--- trunk/reactos/lib/kernel32/file/file.c	2006-01-14 12:42:04 UTC (rev 20849)
+++ trunk/reactos/lib/kernel32/file/file.c	2006-01-14 13:37:08 UTC (rev 20850)
@@ -1600,4 +1600,87 @@
     return TRUE;
 }
 
+
+/*
+ * @implemented
+ */
+DWORD
+WINAPI
+GetFinalPathNameByHandleA(IN HANDLE hFile,
+                          OUT LPSTR lpszFilePath,
+                          IN DWORD cchFilePath,
+                          IN DWORD dwFlags)
+{
+    WCHAR FilePathW[MAX_PATH];
+    UNICODE_STRING FilePathU;
+    DWORD PrevLastError;
+    DWORD Ret = 0;
+
+    if (cchFilePath != 0 &&
+        cchFilePath > sizeof(FilePathW) / sizeof(FilePathW[0]))
+    {
+        FilePathU.Length = 0;
+        FilePathU.MaximumLength = cchFilePath * sizeof(WCHAR);
+        FilePathU.Buffer = RtlAllocateHeap(RtlGetProcessHeap(),
+                                           0,
+                                           FilePathU.MaximumLength);
+        if (FilePathU.Buffer == NULL)
+        {
+            SetLastError(ERROR_NOT_ENOUGH_MEMORY);
+            return 0;
+        }
+    }
+    else
+    {
+        FilePathU.Length = 0;
+        FilePathU.MaximumLength = sizeof(FilePathW);
+        FilePathU.Buffer = FilePathW;
+    }
+
+    /* save the last error code */
+    PrevLastError = GetLastError();
+    SetLastError(ERROR_SUCCESS);
+
+    /* call the unicode version that does all the work */
+    Ret = GetFinalPathNameByHandleW(hFile,
+                                    FilePathU.Buffer,
+                                    cchFilePath,
+                                    dwFlags);
+
+    if (GetLastError() == ERROR_SUCCESS)
+    {
+        /* no error, restore the last error code and convert the string */
+        SetLastError(PrevLastError);
+
+        Ret = FilenameU2A_FitOrFail(lpszFilePath,
+                                    cchFilePath,
+                                    &FilePathU);
+    }
+
+    /* free allocated memory if necessary */
+    if (FilePathU.Buffer != FilePathW)
+    {
+        RtlFreeHeap(RtlGetProcessHeap(),
+                    0,
+                    FilePathU.Buffer);
+    }
+
+    return Ret;
+}
+
+
+/*
+ * @unimplemented
+ */
+DWORD
+WINAPI
+GetFinalPathNameByHandleW(IN HANDLE hFile,
+                          OUT LPWSTR lpszFilePath,
+                          IN DWORD cchFilePath,
+                          IN DWORD dwFlags)
+{
+    UNIMPLEMENTED;
+    return 0;
+}
+
 /* EOF */

Modified: trunk/reactos/lib/kernel32/kernel32.def
--- trunk/reactos/lib/kernel32/kernel32.def	2006-01-14 12:42:04 UTC (rev 20849)
+++ trunk/reactos/lib/kernel32/kernel32.def	2006-01-14 13:37:08 UTC (rev 20850)
@@ -387,6 +387,8 @@
 GetFileSizeEx@8
 GetFileTime@16
 GetFileType@4
+GetFinalPathNameByHandleA@16
+GetFinalPathNameByHandleW@16
 GetFirmwareEnvironmentVariableA@16
 GetFirmwareEnvironmentVariableW@16
 GetFullPathNameA@16

Modified: trunk/reactos/w32api/include/winbase.h
--- trunk/reactos/w32api/include/winbase.h	2006-01-14 12:42:04 UTC (rev 20849)
+++ trunk/reactos/w32api/include/winbase.h	2006-01-14 13:37:08 UTC (rev 20850)
@@ -1368,6 +1368,8 @@
 DWORD WINAPI GetFileAttributesA(LPCSTR);
 #if (_WIN32_WINNT >= 0x0600)
 BOOL WINAPI GetFileAttributesByHandle(HANDLE,LPDWORD,DWORD);
+DWORD WINAPI GetFinalPathNameByHandleA(HANDLE,LPSTR,DWORD,DWORD);
+DWORD WINAPI GetFinalPathNameByHandleW(HANDLE,LPWSTR,DWORD,DWORD);
 #endif
 DWORD WINAPI GetFileAttributesW(LPCWSTR);
 BOOL WINAPI GetFileAttributesExA(LPCSTR,GET_FILEEX_INFO_LEVELS,PVOID);
@@ -2042,8 +2044,11 @@
 #define GetEnvironmentStrings GetEnvironmentStringsW
 #define GetEnvironmentVariable GetEnvironmentVariableW
 #define GetFileAttributes GetFileAttributesW
+#define GetFileAttributesEx GetFileAttributesExW
 #define GetFileSecurity GetFileSecurityW
-#define GetFileAttributesEx GetFileAttributesExW
+#if (_WIN32_WINNT >= 0x0600)
+#define GetFinalPathNameByHandle GetFinalPathNameByHandleW
+#endif
 #define GetFullPathName GetFullPathNameW
 #define GetLogicalDriveStrings GetLogicalDriveStringsW
 #if (_WIN32_WINNT >= 0x0500 || _WIN32_WINDOWS >= 0x0410)
@@ -2241,8 +2246,11 @@
 #define GetDriveType GetDriveTypeA
 #define GetEnvironmentVariable GetEnvironmentVariableA
 #define GetFileAttributes GetFileAttributesA
+#define GetFileAttributesEx GetFileAttributesExA
 #define GetFileSecurity GetFileSecurityA
-#define GetFileAttributesEx GetFileAttributesExA
+#if (_WIN32_WINNT >= 0x0600)
+#define GetFinalPathNameByHandle GetFinalPathNameByHandleA
+#endif
 #define GetFullPathName GetFullPathNameA
 #define GetLogicalDriveStrings GetLogicalDriveStringsA
 #if (_WIN32_WINNT >= 0x0500 || _WIN32_WINDOWS >= 0x0410)