summaryrefslogtreecommitdiffstats
path: root/winsup/cygwin/path.cc
diff options
context:
space:
mode:
Diffstat (limited to 'winsup/cygwin/path.cc')
-rw-r--r--winsup/cygwin/path.cc28
1 files changed, 28 insertions, 0 deletions
diff --git a/winsup/cygwin/path.cc b/winsup/cygwin/path.cc
index 341f8268c..59e454bfc 100644
--- a/winsup/cygwin/path.cc
+++ b/winsup/cygwin/path.cc
@@ -286,6 +286,10 @@ normalize_posix_path (const char *src, char *dst, char **tail)
}
done:
+ /* Remove trailing dots and spaces which are ignored by Win32 functions but
+ not by native NT functions. */
+ while (dst[-1] == '.' || dst[-1] == ' ')
+ --dst;
*dst = '\0';
*tail = dst;
@@ -458,6 +462,30 @@ path_conv::set_normalized_path (const char *path_copy)
memcpy (normalized_path, path_copy, n);
}
+PUNICODE_STRING
+path_conv::get_nt_native_path (UNICODE_STRING &upath, WCHAR *wpath)
+{
+ if (path[0] != '\\') /* X:\... or NUL, etc. */
+ {
+ str2buf2uni (upath, wpath, "\\??\\");
+ str2buf2uni_cat (upath, path);
+ }
+ else if (path[1] != '\\') /* \Device\... */
+ str2buf2uni (upath, wpath, path);
+ else if (path[2] != '.'
+ || path[3] != '\\') /* \\server\share\... */
+ {
+ str2buf2uni (upath, wpath, "\\??\\UNC\\");
+ str2buf2uni_cat (upath, path + 2);
+ }
+ else /* \\.\device */
+ {
+ str2buf2uni (upath, wpath, "\\??\\");
+ str2buf2uni_cat (upath, path + 4);
+ }
+ return &upath;
+}
+
/* Convert an arbitrary path SRC to a pure Win32 path, suitable for
passing to Win32 API routines.