diff --git a/reactos/lib/kernel32/file/file.c b/reactos/lib/kernel32/file/file.c index dd0ddd1858b..bb32e390f6f 100644 --- a/reactos/lib/kernel32/file/file.c +++ b/reactos/lib/kernel32/file/file.c @@ -1600,4 +1600,87 @@ CheckNameLegalDOS8Dot3A( 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 */ diff --git a/reactos/lib/kernel32/kernel32.def b/reactos/lib/kernel32/kernel32.def index fff1240dbb7..9bd572eee4d 100644 --- a/reactos/lib/kernel32/kernel32.def +++ b/reactos/lib/kernel32/kernel32.def @@ -387,6 +387,8 @@ GetFileSize@8 GetFileSizeEx@8 GetFileTime@16 GetFileType@4 +GetFinalPathNameByHandleA@16 +GetFinalPathNameByHandleW@16 GetFirmwareEnvironmentVariableA@16 GetFirmwareEnvironmentVariableW@16 GetFullPathNameA@16 diff --git a/reactos/w32api/include/winbase.h b/reactos/w32api/include/winbase.h index 672f75a5bee..b02506b9a36 100644 --- a/reactos/w32api/include/winbase.h +++ b/reactos/w32api/include/winbase.h @@ -1368,6 +1368,8 @@ BOOL WINAPI GetExitCodeThread(HANDLE,PDWORD); 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 @@ typedef PCACTCTXW PCACTCTX; #define GetEnvironmentStrings GetEnvironmentStringsW #define GetEnvironmentVariable GetEnvironmentVariableW #define GetFileAttributes GetFileAttributesW -#define GetFileSecurity GetFileSecurityW #define GetFileAttributesEx GetFileAttributesExW +#define GetFileSecurity GetFileSecurityW +#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 @@ typedef ENUMRESTYPEPROCA ENUMRESTYPEPROC; #define GetDriveType GetDriveTypeA #define GetEnvironmentVariable GetEnvironmentVariableA #define GetFileAttributes GetFileAttributesA -#define GetFileSecurity GetFileSecurityA #define GetFileAttributesEx GetFileAttributesExA +#define GetFileSecurity GetFileSecurityA +#if (_WIN32_WINNT >= 0x0600) +#define GetFinalPathNameByHandle GetFinalPathNameByHandleA +#endif #define GetFullPathName GetFullPathNameA #define GetLogicalDriveStrings GetLogicalDriveStringsA #if (_WIN32_WINNT >= 0x0500 || _WIN32_WINDOWS >= 0x0410)