summaryrefslogtreecommitdiffstats
path: root/lldb/source/Host/common/FileSpec.cpp
diff options
context:
space:
mode:
authorGreg Clayton <gclayton@apple.com>2013-11-20 21:07:01 +0000
committerGreg Clayton <gclayton@apple.com>2013-11-20 21:07:01 +0000
commitfbb7634934d40548b650574a2f2a85ab41527674 (patch)
tree3b8bb1b8c997ecff27411cf8a16978b3ee7f9c92 /lldb/source/Host/common/FileSpec.cpp
parent884bde303126f5e923fb34e568afd0639af9504a (diff)
downloadbcm5719-llvm-fbb7634934d40548b650574a2f2a85ab41527674.tar.gz
bcm5719-llvm-fbb7634934d40548b650574a2f2a85ab41527674.zip
Expose SBPlatform through the public API.
Example code: remote_platform = lldb.SBPlatform("remote-macosx"); remote_platform.SetWorkingDirectory("/private/tmp") debugger.SetSelectedPlatform(remote_platform) connect_options = lldb.SBPlatformConnectOptions("connect://localhost:1111"); err = remote_platform.ConnectRemote(connect_options) if err.Success(): print >> result, 'Connected to remote platform:' print >> result, 'hostname: %s' % (remote_platform.GetHostname()) src = lldb.SBFileSpec("/Applications/Xcode.app/Contents/SharedFrameworks/LLDB.framework", False) dst = lldb.SBFileSpec() # copy src to platform working directory since "dst" is empty err = remote_platform.Install(src, dst); if err.Success(): print >> result, '%s installed successfully' % (src) else: print >> result, 'error: failed to install "%s": %s' % (src, err) Implemented many calls needed in lldb-platform to be able to install a directory that contains symlinks, file and directories. The remote lldb-platform can now launch GDB servers on the remote system so that remote debugging can be spawned through the remote platform when connected to a remote platform. The API in SBPlatform is subject to change and will be getting many new functions. llvm-svn: 195273
Diffstat (limited to 'lldb/source/Host/common/FileSpec.cpp')
-rw-r--r--lldb/source/Host/common/FileSpec.cpp32
1 files changed, 21 insertions, 11 deletions
diff --git a/lldb/source/Host/common/FileSpec.cpp b/lldb/source/Host/common/FileSpec.cpp
index 33de198072d..48f1ac78d92 100644
--- a/lldb/source/Host/common/FileSpec.cpp
+++ b/lldb/source/Host/common/FileSpec.cpp
@@ -34,6 +34,7 @@
#include "lldb/Core/StreamString.h"
#include "lldb/Host/File.h"
#include "lldb/Host/FileSpec.h"
+#include "lldb/Host/Host.h"
#include "lldb/Core/DataBufferHeap.h"
#include "lldb/Core/DataBufferMemoryMap.h"
#include "lldb/Core/RegularExpression.h"
@@ -646,6 +647,15 @@ FileSpec::GetFileType () const
return eFileTypeInvalid;
}
+uint32_t
+FileSpec::GetPermissions () const
+{
+ uint32_t file_permissions = 0;
+ if (*this)
+ Host::GetFilePermissions(GetPath().c_str(), file_permissions);
+ return file_permissions;
+}
+
TimeValue
FileSpec::GetModificationTime () const
{
@@ -1161,26 +1171,26 @@ FileSpec::CopyByRemovingLastPathComponent () const
return FileSpec(m_directory.GetCString(),resolve);
}
-const char*
+ConstString
FileSpec::GetLastPathComponent () const
{
- if (m_filename.IsEmpty() && m_directory.IsEmpty())
- return NULL;
- if (m_filename.IsEmpty())
+ if (m_filename)
+ return m_filename;
+ if (m_directory)
{
const char* dir_cstr = m_directory.GetCString();
const char* last_slash_ptr = ::strrchr(dir_cstr, '/');
if (last_slash_ptr == NULL)
- return m_directory.GetCString();
+ return m_directory;
if (last_slash_ptr == dir_cstr)
{
if (last_slash_ptr[1] == 0)
- return last_slash_ptr;
+ return ConstString(last_slash_ptr);
else
- return last_slash_ptr+1;
+ return ConstString(last_slash_ptr+1);
}
if (last_slash_ptr[1] != 0)
- return last_slash_ptr+1;
+ return ConstString(last_slash_ptr+1);
const char* penultimate_slash_ptr = last_slash_ptr;
while (*penultimate_slash_ptr)
{
@@ -1190,10 +1200,10 @@ FileSpec::GetLastPathComponent () const
if (*penultimate_slash_ptr == '/')
break;
}
- ConstString new_path(penultimate_slash_ptr+1,last_slash_ptr-penultimate_slash_ptr);
- return new_path.AsCString();
+ ConstString result(penultimate_slash_ptr+1,last_slash_ptr-penultimate_slash_ptr);
+ return result;
}
- return m_filename.GetCString();
+ return ConstString();
}
void
OpenPOWER on IntegriCloud