mirror of
https://github.com/reactos/reactos.git
synced 2025-05-18 00:31:27 +00:00
[LIBWINE] make wine_get_dos_file_name available
And complain loudly when we get a *real* unix file name
This commit is contained in:
parent
9fc0c7a372
commit
a84b0dbe6b
3 changed files with 90 additions and 1 deletions
|
@ -3945,6 +3945,11 @@ QueryDepthSList(
|
|||
|
||||
#endif /* _SLIST_HEADER_ */
|
||||
|
||||
#ifdef __WINESRC__
|
||||
/* Wine specific. Basically MultiByteToWideChar for us. */
|
||||
WCHAR * CDECL wine_get_dos_file_name(LPCSTR str);
|
||||
#endif
|
||||
|
||||
#ifdef _MSC_VER
|
||||
#pragma warning(pop)
|
||||
#endif
|
||||
|
|
4
sdk/lib/3rdparty/libwine/CMakeLists.txt
vendored
4
sdk/lib/3rdparty/libwine/CMakeLists.txt
vendored
|
@ -1,6 +1,5 @@
|
|||
|
||||
include_directories(${REACTOS_SOURCE_DIR}/sdk/include/reactos/wine)
|
||||
add_definitions(-D__WINESRC__)
|
||||
|
||||
list(APPEND SOURCE
|
||||
config.c
|
||||
|
@ -10,12 +9,15 @@ list(APPEND SOURCE
|
|||
isnan.c
|
||||
loader.c
|
||||
${REACTOS_SOURCE_DIR}/sdk/lib/crt/string/wctype.c
|
||||
path.c
|
||||
register.c
|
||||
# string.c implements _stricmp, already shipped with crt
|
||||
)
|
||||
|
||||
add_library(wine ${SOURCE})
|
||||
add_dependencies(wine psdk)
|
||||
target_compile_definitions(wine PRIVATE __WINESRC__ _WINE)
|
||||
|
||||
add_library(wineldr loader.c)
|
||||
add_dependencies(wineldr xdk)
|
||||
target_compile_definitions(wineldr PRIVATE __WINESRC__)
|
||||
|
|
82
sdk/lib/3rdparty/libwine/path.c
vendored
Normal file
82
sdk/lib/3rdparty/libwine/path.c
vendored
Normal file
|
@ -0,0 +1,82 @@
|
|||
/* Copyright 1993 Erik Bos
|
||||
* Copyright 1996, 2004 Alexandre Julliard
|
||||
* Copyright 2003 Eric Pouech
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 2.1 of the License, or (at your option) any later version.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public
|
||||
* License along with this library; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
|
||||
*
|
||||
*/
|
||||
|
||||
#include <windef.h>
|
||||
#include <winbase.h>
|
||||
#include <winnls.h>
|
||||
|
||||
#include <wine/winternl.h>
|
||||
|
||||
#include <wine/debug.h>
|
||||
WINE_DEFAULT_DEBUG_CHANNEL(path);
|
||||
|
||||
static inline BOOL set_ntstatus( NTSTATUS status )
|
||||
{
|
||||
if (status) SetLastError( RtlNtStatusToDosError( status ));
|
||||
return !status;
|
||||
}
|
||||
|
||||
/***********************************************************************
|
||||
* 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 * CDECL wine_get_dos_file_name( LPCSTR str )
|
||||
{
|
||||
UNICODE_STRING nt_name;
|
||||
NTSTATUS status;
|
||||
WCHAR *buffer;
|
||||
SIZE_T len = strlen(str) + 1;
|
||||
|
||||
if (str[0] != '/') /* relative path name */
|
||||
{
|
||||
if (!(buffer = RtlAllocateHeap( GetProcessHeap(), 0, len * sizeof(WCHAR) ))) return NULL;
|
||||
MultiByteToWideChar( CP_UNIXCP, 0, str, len, buffer, len );
|
||||
status = RtlDosPathNameToNtPathName_U_WithStatus( buffer, &nt_name, NULL, NULL );
|
||||
RtlFreeHeap( GetProcessHeap(), 0, buffer );
|
||||
if (!set_ntstatus( status )) return NULL;
|
||||
buffer = nt_name.Buffer;
|
||||
len = nt_name.Length / sizeof(WCHAR) + 1;
|
||||
}
|
||||
else
|
||||
{
|
||||
#ifdef __REACTOS__
|
||||
ERR("Got absolute UNIX path name in function wine_get_dos_file_name. This is not UNIX. Please fix the caller!\n");
|
||||
ERR("File name: %s\n", str);
|
||||
#else
|
||||
len += 8; /* \??\unix prefix */
|
||||
if (!(buffer = HeapAlloc( GetProcessHeap(), 0, len * sizeof(WCHAR) ))) return NULL;
|
||||
if (!set_ntstatus( wine_unix_to_nt_file_name( str, buffer, &len )))
|
||||
{
|
||||
HeapFree( GetProcessHeap(), 0, buffer );
|
||||
return NULL;
|
||||
}
|
||||
#endif
|
||||
}
|
||||
if (buffer[5] == ':')
|
||||
{
|
||||
/* get rid of the \??\ prefix */
|
||||
/* FIXME: should implement RtlNtPathNameToDosPathName and use that instead */
|
||||
memmove( buffer, buffer + 4, (len - 4) * sizeof(WCHAR) );
|
||||
}
|
||||
else buffer[1] = '\\';
|
||||
return buffer;
|
||||
}
|
Loading…
Reference in a new issue