aboutsummaryrefslogtreecommitdiff
path: root/lldb/source/Host/common/FileSpec.cpp
diff options
context:
space:
mode:
authorChaoren Lin <chaorenl@google.com>2015-05-29 19:52:29 +0000
committerChaoren Lin <chaorenl@google.com>2015-05-29 19:52:29 +0000
commitd3173f34e8546a96b8d0df0d9de133f88f10c127 (patch)
tree5e778446085cbd4a4d43fc3b488b3ac6ff17f2b5 /lldb/source/Host/common/FileSpec.cpp
parent375432e4d8f50212bca3d9228e349b5a00f770d7 (diff)
downloadllvm-d3173f34e8546a96b8d0df0d9de133f88f10c127.zip
llvm-d3173f34e8546a96b8d0df0d9de133f88f10c127.tar.gz
llvm-d3173f34e8546a96b8d0df0d9de133f88f10c127.tar.bz2
Refactor many file functions to use FileSpec over strings.
Summary: This should solve the issue of sending denormalized paths over gdb-remote if we stick to GetPath(false) in GDBRemoteCommunicationClient, and let the server handle any denormalization. Reviewers: ovyalov, zturner, vharron, clayborg Reviewed By: clayborg Subscribers: tberghammer, emaste, lldb-commits Differential Revision: http://reviews.llvm.org/D9728 llvm-svn: 238604
Diffstat (limited to 'lldb/source/Host/common/FileSpec.cpp')
-rw-r--r--lldb/source/Host/common/FileSpec.cpp32
1 files changed, 30 insertions, 2 deletions
diff --git a/lldb/source/Host/common/FileSpec.cpp b/lldb/source/Host/common/FileSpec.cpp
index c0efa71..65d6543 100644
--- a/lldb/source/Host/common/FileSpec.cpp
+++ b/lldb/source/Host/common/FileSpec.cpp
@@ -243,7 +243,17 @@ FileSpec::FileSpec(const char *pathname, bool resolve_path, PathSyntax syntax) :
}
FileSpec::FileSpec(const char *pathname, bool resolve_path, ArchSpec arch) :
- FileSpec(pathname, resolve_path, arch.GetTriple().isOSWindows() ? ePathSyntaxWindows : ePathSyntaxPosix)
+ FileSpec{pathname, resolve_path, arch.GetTriple().isOSWindows() ? ePathSyntaxWindows : ePathSyntaxPosix}
+{
+}
+
+FileSpec::FileSpec(const std::string &path, bool resolve_path, PathSyntax syntax) :
+ FileSpec{path.c_str(), resolve_path, syntax}
+{
+}
+
+FileSpec::FileSpec(const std::string &path, bool resolve_path, ArchSpec arch) :
+ FileSpec{path.c_str(), resolve_path, arch}
{
}
@@ -334,6 +344,12 @@ FileSpec::SetFile (const char *pathname, bool resolve, PathSyntax syntax)
m_directory.SetCString(normalized.c_str());
}
+void
+FileSpec::SetFile(const std::string &pathname, bool resolve, PathSyntax syntax)
+{
+ return SetFile(pathname.c_str(), resolve, syntax);
+}
+
//----------------------------------------------------------------------
// Convert to pointer operator. This allows code to check any FileSpec
// objects to see if they contain anything valid using code such as:
@@ -755,7 +771,7 @@ FileSpec::GetPermissions () const
{
uint32_t file_permissions = 0;
if (*this)
- FileSystem::GetFilePermissions(GetPath().c_str(), file_permissions);
+ FileSystem::GetFilePermissions(*this, file_permissions);
return file_permissions;
}
@@ -829,6 +845,12 @@ FileSpec::GetPath(bool denormalize) const
return std::string(result.begin(), result.end());
}
+const char *
+FileSpec::GetCString(bool denormalize) const
+{
+ return ConstString{GetPath(denormalize)}.AsCString(NULL);
+}
+
void
FileSpec::GetPath(llvm::SmallVectorImpl<char> &path, bool denormalize) const
{
@@ -1336,6 +1358,12 @@ FileSpec::AppendPathComponent (const char *new_path)
}
void
+FileSpec::AppendPathComponent(const std::string &new_path)
+{
+ return AppendPathComponent(new_path.c_str());
+}
+
+void
FileSpec::RemoveLastPathComponent ()
{
const bool resolve = false;