diff options
author | Jason Molenda <jmolenda@apple.com> | 2015-02-25 02:35:25 +0000 |
---|---|---|
committer | Jason Molenda <jmolenda@apple.com> | 2015-02-25 02:35:25 +0000 |
commit | 671a29d30d2fe5d5d3bab0123690849f98ac031f (patch) | |
tree | 4e3e98115cb76407a9421169928b4c7a124dab7e /lldb/source/Host/common/FileSpec.cpp | |
parent | b20cd673ff1e60cf48ef5e7a54887a360786efff (diff) | |
download | bcm5719-llvm-671a29d30d2fe5d5d3bab0123690849f98ac031f.tar.gz bcm5719-llvm-671a29d30d2fe5d5d3bab0123690849f98ac031f.zip |
When FileSpec::Resolve is given a bare file like "ls",
and llvm::sys::fs::make_absolute prepends the current
working directory to that path, leave the original
bare file name unchanged if $cwd/ls doesn't exist.
http://reviews.llvm.org/D7477
<rdar://problem/18775190>
llvm-svn: 230451
Diffstat (limited to 'lldb/source/Host/common/FileSpec.cpp')
-rw-r--r-- | lldb/source/Host/common/FileSpec.cpp | 13 |
1 files changed, 13 insertions, 0 deletions
diff --git a/lldb/source/Host/common/FileSpec.cpp b/lldb/source/Host/common/FileSpec.cpp index 19f3b93f087..553764e560d 100644 --- a/lldb/source/Host/common/FileSpec.cpp +++ b/lldb/source/Host/common/FileSpec.cpp @@ -164,7 +164,20 @@ FileSpec::Resolve (llvm::SmallVectorImpl<char> &path) ResolveUsername(path); #endif // #ifdef LLDB_CONFIG_TILDE_RESOLVES_TO_USER + // Save a copy of the original path that's passed in + llvm::SmallString<PATH_MAX> original_path(path.begin(), path.end()); + llvm::sys::fs::make_absolute(path); + + + path.push_back(0); // Be sure we have a nul terminated string + path.pop_back(); + struct stat file_stats; + if (::stat (path.data(), &file_stats) != 0) + { + path.clear(); + path.append(original_path.begin(), original_path.end()); + } } FileSpec::FileSpec() : |