Make an error message a little more intelligible.
[oota-llvm.git] / lib / System / Path.cpp
index 34cbd6d69b7fef691d1ee20de0e176d7fcaf667c..1246038f84fe6fa9a0ccfe87cdb1305b884ae66a 100644 (file)
@@ -14,8 +14,8 @@
 #include "llvm/System/Path.h"
 #include "llvm/Config/config.h"
 #include <cassert>
-
-namespace llvm {
+#include <ostream>
+using namespace llvm;
 using namespace sys;
 
 //===----------------------------------------------------------------------===//
@@ -23,11 +23,16 @@ using namespace sys;
 //===          independent code.
 //===----------------------------------------------------------------------===//
 
+std::ostream& llvm::operator<<(std::ostream &strm, const sys::Path &aPath) {
+  strm << aPath.toString();
+  return strm;
+}
+
 Path
 Path::GetLLVMConfigDir() {
   Path result;
 #ifdef LLVM_ETCDIR
-  if (result.setDirectory(LLVM_ETCDIR))
+  if (result.set(LLVM_ETCDIR))
     return result;
 #endif
   return GetLLVMDefaultConfigDir();
@@ -62,14 +67,14 @@ sys::IdentifyFileType(const char*magic, unsigned length) {
 
 bool
 Path::isArchive() const {
-  if (readable())
+  if (canRead())
     return hasMagicNumber("!<arch>\012");
   return false;
 }
 
 bool
 Path::isDynamicLibrary() const {
-  if (readable())
+  if (canRead())
     return hasMagicNumber("\177ELF");
   return false;
 }
@@ -80,10 +85,10 @@ Path::FindLibrary(std::string& name) {
   GetSystemLibraryPaths(LibPaths);
   for (unsigned i = 0; i < LibPaths.size(); ++i) {
     sys::Path FullPath(LibPaths[i]);
-    FullPath.appendFile("lib" + name + LTDL_SHLIB_EXT);
+    FullPath.appendComponent("lib" + name + LTDL_SHLIB_EXT);
     if (FullPath.isDynamicLibrary())
       return FullPath;
-    FullPath.elideSuffix();
+    FullPath.eraseSuffix();
     FullPath.appendSuffix("a");
     if (FullPath.isArchive())
       return FullPath;
@@ -91,15 +96,11 @@ Path::FindLibrary(std::string& name) {
   return sys::Path();
 }
 
-std::string
-Path::GetDLLSuffix() {
+std::string Path::GetDLLSuffix() {
   return LTDL_SHLIB_EXT;
 }
 
-}
-
 // Include the truly platform-specific parts of this class.
-
 #if defined(LLVM_ON_UNIX)
 #include "Unix/Path.inc"
 #endif
@@ -107,3 +108,4 @@ Path::GetDLLSuffix() {
 #include "Win32/Path.inc"
 #endif
 
+DEFINING_FILE_FOR(SystemPath)