summaryrefslogtreecommitdiffstats
path: root/winsup/cygwin/path.cc
diff options
context:
space:
mode:
authorCorinna Vinschen <corinna@vinschen.de>2000-04-13 06:48:14 +0000
committerCorinna Vinschen <corinna@vinschen.de>2000-04-13 06:48:14 +0000
commita4bf66dd75a60aa4de00f7dee5dc3e085dfd5e11 (patch)
tree691bbb547c104e7a20d756ea5aade247ca4d4202 /winsup/cygwin/path.cc
parent418068d4b03662bc05b9b86bd43e5c94ec29d9fa (diff)
downloadcygnal-a4bf66dd75a60aa4de00f7dee5dc3e085dfd5e11.tar.gz
cygnal-a4bf66dd75a60aa4de00f7dee5dc3e085dfd5e11.tar.bz2
cygnal-a4bf66dd75a60aa4de00f7dee5dc3e085dfd5e11.zip
* path.cc (conv_to_win32_path): Detect a win32 path
if path contains backslashes.
Diffstat (limited to 'winsup/cygwin/path.cc')
-rw-r--r--winsup/cygwin/path.cc28
1 files changed, 24 insertions, 4 deletions
diff --git a/winsup/cygwin/path.cc b/winsup/cygwin/path.cc
index bb439c72d..7cb022fa4 100644
--- a/winsup/cygwin/path.cc
+++ b/winsup/cygwin/path.cc
@@ -884,7 +884,8 @@ mount_info::mount_slash ()
int
mount_info::conv_to_win32_path (const char *src_path, char *win32_path,
- char *full_win32_path, DWORD &devn, int &unit, unsigned *flags)
+ char *full_win32_path, DWORD &devn, int &unit,
+ unsigned *flags)
{
int src_path_len = strlen (src_path);
int trailing_slash_p = (src_path_len > 0
@@ -915,7 +916,10 @@ mount_info::conv_to_win32_path (const char *src_path, char *win32_path,
/* The rule is :'s can't appear in [our] POSIX path names so this is a safe
test; if ':' is present it already be in Win32 form. */
- if (strchr (src_path, ':') != NULL)
+ /* Additional test: If the path has \'s in it, we assume that it's a Win32
+ path, either. */
+ if (strchr (src_path, ':') != NULL
+ || (strchr (src_path, '\\')/* && !strchr (src_path, '/')*/))
{
debug_printf ("%s already win32", src_path);
rc = normalize_win32_path ("", src_path, pathbuf);
@@ -923,9 +927,25 @@ mount_info::conv_to_win32_path (const char *src_path, char *win32_path,
return rc;
/* FIXME: Do we have to worry about trailing_slash_p here? */
if (win32_path != NULL)
- strcpy (win32_path, pathbuf);
+ {
+ /* If src_path is a relativ win32 path, normalize_win32_path
+ adds a leading slash, nevertheless. So we have to test
+ that here */
+ strcpy (win32_path, strchr("/\\", src_path[0]) || src_path[1] == ':'
+ ? pathbuf : pathbuf + 1);
+ }
if (full_win32_path != NULL)
- strcpy (full_win32_path, pathbuf);
+ {
+ *full_win32_path = '\0';
+ /* Add drive if it's a local relative Win32 path */
+ if (! strchr(src_path, ':') && strncmp (src_path, "\\\\", 2))
+ {
+ GetCurrentDirectory (MAX_PATH, full_win32_path);
+ if (src_path[0] == '\\') // drive relative absolute path
+ full_win32_path[2] = '\0';
+ }
+ strcat (full_win32_path, pathbuf);
+ }
*flags = set_flags_from_win32_path (pathbuf);
goto out;
}