summaryrefslogtreecommitdiff
path: root/libiberty/lrealpath.c
diff options
context:
space:
mode:
authorDJ Delorie <dj@delorie.com>2004-06-29 12:51:56 +0000
committerDJ Delorie <dj@delorie.com>2004-06-29 12:51:56 +0000
commit69f2a6fc7a7dc00caa0dbdf88df735c86b38409e (patch)
treec29866e4cee2d9cff16dff905a1edbfb39c22649 /libiberty/lrealpath.c
parentfb9981f79b7b95e95578240bd070c2e880e4a5e7 (diff)
downloadgdb-69f2a6fc7a7dc00caa0dbdf88df735c86b38409e.tar.gz
merge from gcc
Diffstat (limited to 'libiberty/lrealpath.c')
-rw-r--r--libiberty/lrealpath.c30
1 files changed, 30 insertions, 0 deletions
diff --git a/libiberty/lrealpath.c b/libiberty/lrealpath.c
index b001b38ef66..4877753cd66 100644
--- a/libiberty/lrealpath.c
+++ b/libiberty/lrealpath.c
@@ -64,6 +64,12 @@ extern char *canonicalize_file_name (const char *);
# define REALPATH_LIMIT MAXPATHLEN
# endif
# endif
+#else
+ /* cygwin has realpath, so it won't get here. */
+# if defined (_WIN32)
+# define WIN32_LEAN_AND_MEAN
+# include <windows.h> /* for GetFullPathName */
+# endif
#endif
char *
@@ -123,6 +129,30 @@ lrealpath (filename)
}
#endif
+ /* The MS Windows method. If we don't have realpath, we assume we
+ don't have symlinks and just canonicalize to a Windows absolute
+ path. GetFullPath converts ../ and ./ in relative paths to
+ absolute paths, filling in current drive if one is not given
+ or using the current directory of a specified drive (eg, "E:foo").
+ It also converts all forward slashes to back slashes. */
+#if defined (_WIN32)
+ {
+ char buf[MAX_PATH];
+ char* basename;
+ DWORD len = GetFullPathName (filename, MAX_PATH, buf, &basename);
+ if (len == 0 || len > MAX_PATH - 1)
+ return strdup (filename);
+ else
+ {
+ /* The file system is case-preserving but case-insensitive,
+ Canonicalize to lowercase, using the codepage associated
+ with the process locale. */
+ CharLowerBuff (buf, len);
+ return strdup (buf);
+ }
+ }
+#endif
+
/* This system is a lost cause, just duplicate the filename. */
return strdup (filename);
}