kernel: Add a wine_get_unix_real_name function to parallel
wine_get_unix_file_name
Jeremy White
jwhite at codeweavers.com
Fri Oct 27 11:15:25 CDT 2006
The new function allows a user to get a simplified path, rather than the actual path
(e.g. /var instead of /home/myuser/.wine/dosdevices/z:/var/)
-------------- next part --------------
>From 601dbb383d77d4a3faaf8058b85684118218f19d Mon Sep 17 00:00:00 2001
From: Jeremy White <jwhite at codeweavers.com>
Date: Fri, 27 Oct 2006 10:29:07 -0500
Subject: Add a wine_get_unix_real_name to provide a way for a caller
to get a simplified path.
---
dlls/kernel/kernel32.spec | 1 +
dlls/kernel/path.c | 49 +++++++++++++++++++++++++++++++++++++++++++++
2 files changed, 50 insertions(+), 0 deletions(-)
diff --git a/dlls/kernel/kernel32.spec b/dlls/kernel/kernel32.spec
index 09cfc8b..4d9eff6 100644
--- a/dlls/kernel/kernel32.spec
+++ b/dlls/kernel/kernel32.spec
@@ -1235,6 +1235,7 @@ # 16-bit relays
# Unix files
@ cdecl wine_get_unix_file_name(wstr)
+@ cdecl wine_get_unix_real_name(wstr)
@ cdecl wine_get_dos_file_name(str)
# Init code
diff --git a/dlls/kernel/path.c b/dlls/kernel/path.c
index c4d7677..eb924f3 100644
--- a/dlls/kernel/path.c
+++ b/dlls/kernel/path.c
@@ -27,6 +27,8 @@ #include "wine/port.h"
#include <errno.h>
#include <stdio.h>
#include <stdarg.h>
+#include <stdlib.h>
+#include <limits.h>
#define NONAMELESSUNION
#define NONAMELESSSTRUCT
@@ -1507,6 +1509,53 @@ char *wine_get_unix_file_name( LPCWSTR d
return unix_name.Buffer;
}
+/***********************************************************************
+ * wine_get_unix_real_name (KERNEL32.@) Not a Windows API
+ *
+ * Return the full Unix file name for a given path, passing the result
+ * through realpath()
+ */
+char *wine_get_unix_real_name( LPCWSTR dosW )
+{
+ UNICODE_STRING nt_name;
+ ANSI_STRING unix_name;
+ NTSTATUS status;
+ int path_max;
+ char *real_unix_name;
+
+ 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)
+ {
+ SetLastError( RtlNtStatusToDosError( status ) );
+ return NULL;
+ }
+
+ #if defined(PATH_MAX)
+ path_max = PATH_MAX;
+ #else
+ path_max = pathconf(unix_name.Buffer, _PC_PATH_MAX);
+ if (path_max <= 0)
+ path_max = 4096;
+ #endif
+
+ if (!(real_unix_name = RtlAllocateHeap( GetProcessHeap(), 0, path_max )))
+ {
+ RtlFreeAnsiString ( &unix_name );
+ SetLastError( ERROR_NOT_ENOUGH_MEMORY );
+ return NULL;
+ }
+
+ if (realpath(unix_name.Buffer, real_unix_name))
+ {
+ RtlFreeAnsiString ( &unix_name );
+ return real_unix_name;
+ }
+
+ return unix_name.Buffer;
+}
+
/***********************************************************************
* wine_get_dos_file_name (KERNEL32.@) Not a Windows API
--
1.4.3.2
More information about the wine-patches
mailing list