ReactOS 0.4.15-dev-7704-gc07eb9f
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
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;
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 /* Return empty path */
66#else
67 len += 8; /* \??\unix prefix */
68 if (!(buffer = HeapAlloc( GetProcessHeap(), 0, len * sizeof(WCHAR) ))) return NULL;
70 {
72 return NULL;
73 }
74#endif
75 }
76 if (buffer[5] == ':')
77 {
78 /* get rid of the \??\ prefix */
79 /* FIXME: should implement RtlNtPathNameToDosPathName and use that instead */
80 memmove( buffer, buffer + 4, (len - 4) * sizeof(WCHAR) );
81 }
82 else buffer[1] = '\\';
83 return buffer;
84}
ACPI_SIZE strlen(const char *String)
Definition: utclib.c:269
#define WINE_DEFAULT_DEBUG_CHANNEL(t)
Definition: precomp.h:23
LONG NTSTATUS
Definition: precomp.h:26
#define ERR(fmt,...)
Definition: debug.h:110
PVOID NTAPI RtlAllocateHeap(IN PVOID HeapHandle, IN ULONG Flags, IN SIZE_T Size)
Definition: heap.c:588
BOOLEAN NTAPI RtlFreeHeap(IN PVOID HeapHandle, IN ULONG Flags, IN PVOID HeapBase)
Definition: heap.c:606
#define NULL
Definition: types.h:112
#define CDECL
Definition: compat.h:29
#define CP_UNIXCP
Definition: compat.h:79
#define GetProcessHeap()
Definition: compat.h:736
#define SetLastError(x)
Definition: compat.h:752
#define HeapAlloc
Definition: compat.h:733
#define HeapFree(x, y, z)
Definition: compat.h:735
#define wine_get_dos_file_name(__x)
Definition: compat.h:61
#define MultiByteToWideChar
Definition: compat.h:110
#define HEAP_ZERO_MEMORY
Definition: compat.h:134
unsigned int BOOL
Definition: ntddk_ex.h:94
GLuint buffer
Definition: glext.h:5915
GLenum GLsizei len
Definition: glext.h:6722
NTSYSAPI ULONG WINAPI RtlNtStatusToDosError(NTSTATUS)
NTSYSAPI NTSTATUS WINAPI RtlDosPathNameToNtPathName_U_WithStatus(PCWSTR, PUNICODE_STRING, PWSTR *, CURDIR *)
NTSYSAPI NTSTATUS CDECL wine_unix_to_nt_file_name(const ANSI_STRING *name, UNICODE_STRING *nt)
#define memmove(s1, s2, n)
Definition: mkisofs.h:881
#define UNICODE_NULL
const WCHAR * str
static BOOL set_ntstatus(NTSTATUS status)
Definition: path.c:30
Definition: ps.c:97
ULONG_PTR SIZE_T
Definition: typedefs.h:80
const char * LPCSTR
Definition: xmlstorage.h:183
__wchar_t WCHAR
Definition: xmlstorage.h:180