ReactOS  0.4.15-dev-1150-g593bcce
path.c
Go to the documentation of this file.
1 /* Copyright 1993 Erik Bos
2  * Copyright 1996, 2004 Alexandre Julliard
3  * Copyright 2003 Eric Pouech
4  *
5  * This library is free software; you can redistribute it and/or
6  * modify it under the terms of the GNU Lesser General Public
7  * License as published by the Free Software Foundation; either
8  * version 2.1 of the License, or (at your option) any later version.
9  *
10  * This library is distributed in the hope that it will be useful,
11  * but WITHOUT ANY WARRANTY; without even the implied warranty of
12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13  * Lesser General Public License for more details.
14  *
15  * You should have received a copy of the GNU Lesser General Public
16  * License along with this library; if not, write to the Free Software
17  * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
18  *
19  */
20 
21 #include <windef.h>
22 #include <winbase.h>
23 #include <winnls.h>
24 
25 #include <wine/winternl.h>
26 
27 #include <wine/debug.h>
29 
30 static inline BOOL set_ntstatus( NTSTATUS status )
31 {
33  return !status;
34 }
35 
36 /***********************************************************************
37  * wine_get_dos_file_name (KERNEL32.@) Not a Windows API
38  *
39  * Return the full DOS file name for a given Unix path.
40  * Returned buffer must be freed by caller.
41  */
43 {
44  UNICODE_STRING nt_name;
46  WCHAR *buffer;
47  SIZE_T len = strlen(str) + 1;
48 
49  if (str[0] != '/') /* relative path name */
50  {
51  if (!(buffer = RtlAllocateHeap( GetProcessHeap(), 0, len * sizeof(WCHAR) ))) return NULL;
55  if (!set_ntstatus( status )) return NULL;
56  buffer = nt_name.Buffer;
57  len = nt_name.Length / sizeof(WCHAR) + 1;
58  }
59  else
60  {
61 #ifdef __REACTOS__
62  ERR("Got absolute UNIX path name in function wine_get_dos_file_name. This is not UNIX. Please fix the caller!\n");
63  ERR("File name: %s\n", str);
64 #else
65  len += 8; /* \??\unix prefix */
66  if (!(buffer = HeapAlloc( GetProcessHeap(), 0, len * sizeof(WCHAR) ))) return NULL;
68  {
70  return NULL;
71  }
72 #endif
73  }
74  if (buffer[5] == ':')
75  {
76  /* get rid of the \??\ prefix */
77  /* FIXME: should implement RtlNtPathNameToDosPathName and use that instead */
78  memmove( buffer, buffer + 4, (len - 4) * sizeof(WCHAR) );
79  }
80  else buffer[1] = '\\';
81  return buffer;
82 }
#define memmove(s1, s2, n)
Definition: mkisofs.h:881
ACPI_SIZE strlen(const char *String)
Definition: utclib.c:269
LONG NTSTATUS
Definition: precomp.h:26
BOOLEAN NTAPI RtlFreeHeap(IN PVOID HeapHandle, IN ULONG Flags, IN PVOID HeapBase)
Definition: heap.c:606
GLuint buffer
Definition: glext.h:5915
NTSTATUS NTAPI RtlDosPathNameToNtPathName_U_WithStatus(IN PCWSTR DosName, OUT PUNICODE_STRING NtName, OUT PCWSTR *PartName, OUT PRTL_RELATIVE_NAME_U RelativeName)
Definition: path.c:1907
NTSYSAPI ULONG WINAPI RtlNtStatusToDosError(NTSTATUS)
unsigned int BOOL
Definition: ntddk_ex.h:94
const WCHAR * str
smooth NULL
Definition: ftsmooth.c:416
const char * LPCSTR
Definition: xmlstorage.h:183
PVOID NTAPI RtlAllocateHeap(IN PVOID HeapHandle, IN ULONG Flags, IN SIZE_T Size)
Definition: heap.c:588
#define GetProcessHeap()
Definition: compat.h:484
PVOID WINAPI HeapAlloc(HANDLE, DWORD, SIZE_T)
#define CP_UNIXCP
Definition: compat.h:79
__wchar_t WCHAR
Definition: xmlstorage.h:180
NTSYSAPI NTSTATUS CDECL wine_unix_to_nt_file_name(const ANSI_STRING *name, UNICODE_STRING *nt)
#define SetLastError(x)
Definition: compat.h:500
GLenum GLsizei len
Definition: glext.h:6722
WINE_DEFAULT_DEBUG_CHANNEL(dbghelp)
#define ERR(fmt,...)
Definition: debug.h:110
ULONG_PTR SIZE_T
Definition: typedefs.h:80
#define CDECL
Definition: compat.h:29
#define MultiByteToWideChar
Definition: compat.h:110
static BOOL set_ntstatus(NTSTATUS status)
Definition: path.c:30
static SERVICE_STATUS status
Definition: service.c:31
WCHAR *CDECL wine_get_dos_file_name(LPCSTR str)
Definition: path.c:42
#define HeapFree(x, y, z)
Definition: compat.h:483
Definition: ps.c:97