Author: spyffe Date: Fri Sep 18 17:24:57 2015 New Revision: 248055 URL: http://llvm.org/viewvc/llvm-project?rev=248055&view=rev Log: Moved ResolveSymbolicLink() to the FileSystem where it belongs, thanks zturner!
http://reviews.llvm.org/D12984 Modified: lldb/trunk/include/lldb/Host/FileSpec.h lldb/trunk/include/lldb/Host/FileSystem.h lldb/trunk/source/Host/common/FileSpec.cpp lldb/trunk/source/Host/common/HostInfoBase.cpp lldb/trunk/source/Host/posix/FileSystem.cpp lldb/trunk/source/Host/windows/FileSystem.cpp Modified: lldb/trunk/include/lldb/Host/FileSpec.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Host/FileSpec.h?rev=248055&r1=248054&r2=248055&view=diff ============================================================================== --- lldb/trunk/include/lldb/Host/FileSpec.h (original) +++ lldb/trunk/include/lldb/Host/FileSpec.h Fri Sep 18 17:24:57 2015 @@ -511,9 +511,6 @@ public: bool IsSymbolicLink () const; - - FileSpec - ResolveSymbolicLink () const; //------------------------------------------------------------------ /// Get the memory cost of this object. Modified: lldb/trunk/include/lldb/Host/FileSystem.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Host/FileSystem.h?rev=248055&r1=248054&r2=248055&view=diff ============================================================================== --- lldb/trunk/include/lldb/Host/FileSystem.h (original) +++ lldb/trunk/include/lldb/Host/FileSystem.h Fri Sep 18 17:24:57 2015 @@ -39,6 +39,8 @@ class FileSystem 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, Modified: lldb/trunk/source/Host/common/FileSpec.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Host/common/FileSpec.cpp?rev=248055&r1=248054&r2=248055&view=diff ============================================================================== --- lldb/trunk/source/Host/common/FileSpec.cpp (original) +++ lldb/trunk/source/Host/common/FileSpec.cpp Fri Sep 18 17:24:57 2015 @@ -811,32 +811,6 @@ FileSpec::IsSymbolicLink () const #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 { Modified: lldb/trunk/source/Host/common/HostInfoBase.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Host/common/HostInfoBase.cpp?rev=248055&r1=248054&r2=248055&view=diff ============================================================================== --- lldb/trunk/source/Host/common/HostInfoBase.cpp (original) +++ lldb/trunk/source/Host/common/HostInfoBase.cpp Fri Sep 18 17:24:57 2015 @@ -308,7 +308,7 @@ HostInfoBase::ComputeSharedLibraryDirect 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(); Modified: lldb/trunk/source/Host/posix/FileSystem.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Host/posix/FileSystem.cpp?rev=248055&r1=248054&r2=248055&view=diff ============================================================================== --- lldb/trunk/source/Host/posix/FileSystem.cpp (original) +++ lldb/trunk/source/Host/posix/FileSystem.cpp Fri Sep 18 17:24:57 2015 @@ -226,6 +226,28 @@ FileSystem::Readlink(const FileSpec &src 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) { Modified: lldb/trunk/source/Host/windows/FileSystem.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Host/windows/FileSystem.cpp?rev=248055&r1=248054&r2=248055&view=diff ============================================================================== --- lldb/trunk/source/Host/windows/FileSystem.cpp (original) +++ lldb/trunk/source/Host/windows/FileSystem.cpp Fri Sep 18 17:24:57 2015 @@ -199,6 +199,12 @@ FileSystem::Readlink(const FileSpec &src return error; } +Error +FileSystem::ResolveSymbolicLink(const FileSpec &src, FileSpec &dst) +{ + return Error("ResolveSymbolicLink() isn't implemented on Windows"); +} + bool FileSystem::IsLocal(const FileSpec &spec) { _______________________________________________ lldb-commits mailing list lldb-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits