diff options
Diffstat (limited to 'source/Target/TargetList.cpp')
| -rw-r--r-- | source/Target/TargetList.cpp | 33 |
1 files changed, 16 insertions, 17 deletions
diff --git a/source/Target/TargetList.cpp b/source/Target/TargetList.cpp index 0637cffddcc1..0849c18b89e0 100644 --- a/source/Target/TargetList.cpp +++ b/source/Target/TargetList.cpp @@ -7,12 +7,8 @@ // //===----------------------------------------------------------------------===// -// C Includes -// C++ Includes -// Other libraries and framework includes -#include "llvm/ADT/SmallString.h" - // Project includes +#include "lldb/Target/TargetList.h" #include "lldb/Core/Broadcaster.h" #include "lldb/Core/Debugger.h" #include "lldb/Core/Event.h" @@ -27,7 +23,11 @@ #include "lldb/Symbol/ObjectFile.h" #include "lldb/Target/Platform.h" #include "lldb/Target/Process.h" -#include "lldb/Target/TargetList.h" +#include "lldb/Utility/TildeExpressionResolver.h" + +// Other libraries and framework includes +#include "llvm/ADT/SmallString.h" +#include "llvm/Support/FileSystem.h" using namespace lldb; using namespace lldb_private; @@ -348,10 +348,10 @@ Error TargetList::CreateTargetInternal(Debugger &debugger, FileSpec file(user_exe_path, false); if (!file.Exists() && user_exe_path.startswith("~")) { // we want to expand the tilde but we don't want to resolve any symbolic - // links - // so we can't use the FileSpec constructor's resolve flag - llvm::SmallString<64> unglobbed_path(user_exe_path); - FileSpec::ResolveUsername(unglobbed_path); + // links so we can't use the FileSpec constructor's resolve flag + llvm::SmallString<64> unglobbed_path; + StandardTildeExpressionResolver Resolver; + Resolver.ResolveFullPath(user_exe_path, unglobbed_path); if (unglobbed_path.empty()) file = FileSpec(user_exe_path, false); @@ -363,18 +363,17 @@ Error TargetList::CreateTargetInternal(Debugger &debugger, char resolved_bundle_exe_path[PATH_MAX]; resolved_bundle_exe_path[0] = '\0'; if (file) { - if (file.GetFileType() == FileSpec::eFileTypeDirectory) + if (llvm::sys::fs::is_directory(file.GetPath())) user_exe_path_is_bundle = true; if (file.IsRelative() && !user_exe_path.empty()) { // Ignore paths that start with "./" and "../" if (!user_exe_path.startswith("./") && !user_exe_path.startswith("../")) { - char cwd[PATH_MAX]; - if (getcwd(cwd, sizeof(cwd))) { - std::string cwd_user_exe_path(cwd); - cwd_user_exe_path += '/'; - cwd_user_exe_path += user_exe_path; - FileSpec cwd_file(cwd_user_exe_path, false); + llvm::SmallString<64> cwd; + if (! llvm::sys::fs::current_path(cwd)) { + cwd += '/'; + cwd += user_exe_path; + FileSpec cwd_file(cwd, false); if (cwd_file.Exists()) file = cwd_file; } |
