From 659b480b8ac8d798fe6a916a5570d8c1f23345cf Mon Sep 17 00:00:00 2001 From: Corinna Vinschen Date: Thu, 22 Feb 2001 16:26:13 +0000 Subject: [PATCH] * path.cc (symlink): Keep relative paths relative in the DOS path inside of a shortcut. If that's impossible or the target path is already absolute save an absolute path. --- winsup/cygwin/ChangeLog | 4 ++-- winsup/cygwin/path.cc | 21 ++++++++++++--------- 2 files changed, 14 insertions(+), 11 deletions(-) diff --git a/winsup/cygwin/ChangeLog b/winsup/cygwin/ChangeLog index 9dd5df3a5..2cd504b6c 100644 --- a/winsup/cygwin/ChangeLog +++ b/winsup/cygwin/ChangeLog @@ -1,8 +1,8 @@ Thu Feb 22 17:09:00 2001 Corinna Vinschen * path.cc (symlink): Keep relative paths relative in the DOS - path inside of a shortcut. If that's impossible for some - reason, save an absolute path. + path inside of a shortcut. If that's impossible or the target + path is already absolute save an absolute path. Thu Feb 22 15:33:00 2001 Corinna Vinschen diff --git a/winsup/cygwin/path.cc b/winsup/cygwin/path.cc index 54db24f8d..f0b48f844 100644 --- a/winsup/cygwin/path.cc +++ b/winsup/cygwin/path.cc @@ -2209,7 +2209,7 @@ symlink (const char *topath, const char *frompath) strcpy (from + len, ".lnk"); path_conv win32_path (from, PC_SYM_NOFOLLOW); path_conv win32_topath; - char cwd[MAX_PATH + 1], *cp, c = 0; + char cwd[MAX_PATH + 1], *cp = NULL, c = 0; char w32topath[MAX_PATH + 1]; #endif @@ -2265,18 +2265,21 @@ symlink (const char *topath, const char *frompath) res = 0; } #else - getcwd (cwd, MAX_PATH + 1); - if ((cp = strrchr (from, '/')) || (cp = strrchr (from, '\\'))) + if (!isabspath (topath)) { - c = *cp; - *cp = '\0'; - chdir (from); + getcwd (cwd, MAX_PATH + 1); + if ((cp = strrchr (from, '/')) || (cp = strrchr (from, '\\'))) + { + c = *cp; + *cp = '\0'; + chdir (from); + } + backslashify (topath, w32topath, 0); } - backslashify (topath, w32topath, 0); - if (GetFileAttributes (w32topath) == (DWORD)-1) + if (!cp || GetFileAttributes (w32topath) == (DWORD)-1) { win32_topath.check (topath, PC_SYM_NOFOLLOW); - if (win32_topath.error != ENOENT) + if (!cp || win32_topath.error != ENOENT) strcpy (w32topath, win32_topath); } if (cp)