spyffe updated this revision to Diff 35144.
spyffe added a comment.

Restored the old name based on zturner's suggestion that Realpath() is too 
specific and has semantics that Windows wouldn't honor.


http://reviews.llvm.org/D12984

Files:
  include/lldb/Host/FileSpec.h
  include/lldb/Host/FileSystem.h
  source/Host/common/FileSpec.cpp
  source/Host/common/HostInfoBase.cpp
  source/Host/posix/FileSystem.cpp
  source/Host/windows/FileSystem.cpp

Index: source/Host/windows/FileSystem.cpp
===================================================================
--- source/Host/windows/FileSystem.cpp
+++ source/Host/windows/FileSystem.cpp
@@ -199,6 +199,12 @@
     return error;
 }
 
+Error
+FileSystem::ResolveSymbolicLink(const FileSpec &src, FileSpec &dst)
+{
+    return Error("ResolveSymbolicLink() isn't implemented on Windows");
+}
+
 bool
 FileSystem::IsLocal(const FileSpec &spec)
 {
Index: source/Host/posix/FileSystem.cpp
===================================================================
--- source/Host/posix/FileSystem.cpp
+++ source/Host/posix/FileSystem.cpp
@@ -226,6 +226,28 @@
     return error;
 }
 
+Error
+FileSystem::ResolveSymbolicLink(const FileSpec &src, FileSpec &dst)
+{
+    char resolved_path[PATH_MAX];
+    if (!src.GetPath (resolved_path, sizeof (resolved_path)))
+    {
+        return Error("Couldn't get the canonical path for %s", src.GetCString());
+    }
+    
+    char real_path[PATH_MAX + 1];
+    if (realpath(resolved_path, real_path) == nullptr)
+    {
+        Error err;
+        err.SetErrorToErrno();
+        return err;
+    }
+    
+    dst = FileSpec(real_path, false);
+    
+    return Error();
+}
+
 #if defined(__NetBSD__)
 static bool IsLocal(const struct statvfs& info)
 {
Index: source/Host/common/HostInfoBase.cpp
===================================================================
--- source/Host/common/HostInfoBase.cpp
+++ source/Host/common/HostInfoBase.cpp
@@ -308,7 +308,7 @@
         Host::GetModuleFileSpecForHostAddress(reinterpret_cast<void *>(reinterpret_cast<intptr_t>(HostInfoBase::GetLLDBPath))));
     
     // This is necessary because when running the testsuite the shlib might be a symbolic link inside the Python resource dir.
-    lldb_file_spec = lldb_file_spec.ResolveSymbolicLink();
+    FileSystem::ResolveSymbolicLink(lldb_file_spec, lldb_file_spec);
     
     // Remove the filename so that this FileSpec only represents the directory.
     file_spec.GetDirectory() = lldb_file_spec.GetDirectory();
Index: source/Host/common/FileSpec.cpp
===================================================================
--- source/Host/common/FileSpec.cpp
+++ source/Host/common/FileSpec.cpp
@@ -811,32 +811,6 @@
 #endif
 }
 
-FileSpec
-FileSpec::ResolveSymbolicLink () const {
-    if (!IsSymbolicLink())
-    {
-        return *this;
-    }
-        
-    char resolved_path[PATH_MAX];
-    if (!GetPath (resolved_path, sizeof (resolved_path)))
-    {
-        return *this;
-    }
-        
-#ifdef _WIN32
-    return *this; // TODO make this work on win32
-#else
-    char real_path[PATH_MAX + 1];
-    if (realpath(resolved_path, real_path) == nullptr)
-    {
-        return *this;
-    }
-    
-    return FileSpec(real_path, false);
-#endif
-}
-
 uint32_t
 FileSpec::GetPermissions () const
 {
Index: include/lldb/Host/FileSystem.h
===================================================================
--- include/lldb/Host/FileSystem.h
+++ include/lldb/Host/FileSystem.h
@@ -39,6 +39,8 @@
     static Error Symlink(const FileSpec &src, const FileSpec &dst);
     static Error Readlink(const FileSpec &src, FileSpec &dst);
     static Error Unlink(const FileSpec &file_spec);
+    
+    static Error ResolveSymbolicLink(const FileSpec &src, FileSpec &dst);
 
     static bool CalculateMD5(const FileSpec &file_spec, uint64_t &low, uint64_t &high);
     static bool CalculateMD5(const FileSpec &file_spec,
Index: include/lldb/Host/FileSpec.h
===================================================================
--- include/lldb/Host/FileSpec.h
+++ include/lldb/Host/FileSpec.h
@@ -511,9 +511,6 @@
 
     bool
     IsSymbolicLink () const;
-    
-    FileSpec
-    ResolveSymbolicLink () const;
 
     //------------------------------------------------------------------
     /// Get the memory cost of this object.
_______________________________________________
lldb-commits mailing list
lldb-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits

Reply via email to