summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authordannysmith <dannysmith@138bc75d-0d04-0410-961f-82ee72b054a4>2004-06-29 11:37:20 +0000
committerdannysmith <dannysmith@138bc75d-0d04-0410-961f-82ee72b054a4>2004-06-29 11:37:20 +0000
commitc295e612e9fe12d597278539b6e7b7080df93787 (patch)
treeb5da2aaeee765d7fddc7920c266f1d75f1a0f0ae
parenta8ff8672e47ffbff9e692a382a02a35f695d693a (diff)
downloadppe42-gcc-c295e612e9fe12d597278539b6e7b7080df93787.tar.gz
ppe42-gcc-c295e612e9fe12d597278539b6e7b7080df93787.zip
* lrealpath.c (lrealpath): Add _WIN32 support.
git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@83853 138bc75d-0d04-0410-961f-82ee72b054a4
-rw-r--r--libiberty/ChangeLog4
-rw-r--r--libiberty/lrealpath.c30
2 files changed, 34 insertions, 0 deletions
diff --git a/libiberty/ChangeLog b/libiberty/ChangeLog
index 6458c2afe62..f8e1c9c5bff 100644
--- a/libiberty/ChangeLog
+++ b/libiberty/ChangeLog
@@ -1,3 +1,7 @@
+2004-06-29 Danny Smith <dannysmith@users.sourceforge.net>
+
+ * lrealpath.c (lrealpath): Add _WIN32 support.
+
2004-06-28 Zack Weinberg <zack@codesourcery.com>
* cp-demangle.h: Declare cplus_demangle_operators,
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);
}
OpenPOWER on IntegriCloud