From e859359211061848fc84237c32f8e2338316d797 Mon Sep 17 00:00:00 2001 From: Alexandre Julliard Date: Thu, 11 Aug 2005 11:07:17 +0000 Subject: [PATCH] Added a wine_get_dos_file_name function in kernel32 as a wrapper around the new wine_unix_to_nt_file_name. --- dlls/kernel/kernel32.spec | 1 + dlls/kernel/path.c | 35 ++++++++++++++++++++++++++++++++++- include/winbase.h | 1 + 3 files changed, 36 insertions(+), 1 deletion(-) diff --git a/dlls/kernel/kernel32.spec b/dlls/kernel/kernel32.spec index e6b0f1a5526..80652d99134 100644 --- a/dlls/kernel/kernel32.spec +++ b/dlls/kernel/kernel32.spec @@ -1261,6 +1261,7 @@ # Unix files @ cdecl wine_get_unix_file_name(wstr) +@ cdecl wine_get_dos_file_name(str) # Init code @ cdecl __wine_kernel_init() diff --git a/dlls/kernel/path.c b/dlls/kernel/path.c index be710659ca5..36c41ae17f4 100644 --- a/dlls/kernel/path.c +++ b/dlls/kernel/path.c @@ -1485,6 +1485,39 @@ char *wine_get_unix_file_name( LPCWSTR dosW ) if (!RtlDosPathNameToNtPathName_U( dosW, &nt_name, NULL, NULL )) return NULL; status = wine_nt_to_unix_file_name( &nt_name, &unix_name, FILE_OPEN_IF, FALSE ); RtlFreeUnicodeString( &nt_name ); - if (status && status != STATUS_NO_SUCH_FILE) return NULL; + if (status && status != STATUS_NO_SUCH_FILE) + { + SetLastError( RtlNtStatusToDosError( status ) ); + return NULL; + } return unix_name.Buffer; } + + +/*********************************************************************** + * wine_get_dos_file_name (KERNEL32.@) Not a Windows API + * + * Return the full DOS file name for a given Unix path. + * Returned buffer must be freed by caller. + */ +WCHAR *wine_get_dos_file_name( LPCSTR str ) +{ + UNICODE_STRING nt_name; + ANSI_STRING unix_name; + NTSTATUS status; + DWORD len; + + RtlInitAnsiString( &unix_name, str ); + status = wine_unix_to_nt_file_name( &unix_name, &nt_name ); + if (status) + { + SetLastError( RtlNtStatusToDosError( status ) ); + return NULL; + } + /* get rid of the \??\ prefix */ + /* FIXME: should implement RtlNtPathNameToDosPathName and use that instead */ + len = nt_name.Length - 4 * sizeof(WCHAR); + memmove( nt_name.Buffer, nt_name.Buffer + 4, len ); + nt_name.Buffer[len / sizeof(WCHAR)] = 0; + return nt_name.Buffer; +} diff --git a/include/winbase.h b/include/winbase.h index c84b232c765..a842e188d01 100644 --- a/include/winbase.h +++ b/include/winbase.h @@ -2169,6 +2169,7 @@ VOID WINAPI _LeaveSysLevel(SYSLEVEL*); /* Wine internal functions */ extern char *wine_get_unix_file_name( LPCWSTR dos ); +extern WCHAR *wine_get_dos_file_name( LPCSTR str ); /* a few optimizations for i386/gcc */