Rip out realpath() support. It's expensive, and often a bad idea, and
authorDouglas Gregor <dgregor@apple.com>
Wed, 9 Feb 2011 23:33:15 +0000 (23:33 +0000)
committerDouglas Gregor <dgregor@apple.com>
Wed, 9 Feb 2011 23:33:15 +0000 (23:33 +0000)
I have another way to achieve the same goal.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@125239 91177308-0d34-0410-b5e6-96231b3b80d8

include/llvm/Support/PathV2.h
lib/Support/Unix/PathV2.inc

index 976fa6a7b2576a345bf329139f2e9d8c69678e4d..3866e410e62413c79c67b1733aaeefecd23ba85a 100644 (file)
@@ -244,15 +244,6 @@ const StringRef filename(StringRef path);
 /// @result The stem of \a path.
 const StringRef stem(StringRef path);
 
-/// Convert path to a canonical form, resolving symbolic links and removing
-/// unnecessary path elements (e.g., "foo/../", "./"). 
-///
-/// @param path A path that is going to be canonicalized by resolving symlinks
-/// and removing unnecessary path elements (e.g., "./").
-///
-/// @param buffer The resulting canonical path.
-void canonical(const char *path, SmallVectorImpl<char> &result);
-  
 /// @brief Get extension.
 ///
 /// If filename contains a dot but not solely one or two dots, result is the
index 3a3a438d05b9c84f806e3f9f5b61a5112431fef1..03ff28367e44c5e653f6080e5e89e43aaec714f5 100644 (file)
@@ -503,35 +503,5 @@ error_code get_magic(const Twine &path, uint32_t len,
 }
 
 } // end namespace fs
-
-namespace path {
-
-void canonical(const char *path, SmallVectorImpl<char> &buffer) {
-  buffer.resize(PATH_MAX);
-  char *result = realpath(path, buffer.data());
-  if (result) {
-    buffer.resize(strlen(result));
-    return;
-  }
-
-  // A common extension is to support memory allocation of the result when
-  // passing NULL as the second argument.
-  result = realpath(path, 0);
-  if (result) {
-    size_t length = strlen(result);
-    buffer.resize(length);
-    memcpy(buffer.data(), result, length);
-    free(result);
-    return;
-  }
-
-  size_t length = strlen(path);
-  buffer.resize(length);
-  memcpy(buffer.data(), path, length);
-  return;
-}
-
-} // end namespace path
-
 } // end namespace sys
 } // end namespace llvm