[Lldb-commits] [lldb] r154836 - in /lldb/branches/lldb-platform-work: include/lldb/Host/FileSpec.h source/Commands/CommandObjectPlatform.cpp source/Host/common/FileSpec.cpp
Enrico Granata
egranata at apple.com
Mon Apr 16 10:32:45 PDT 2012
Author: enrico
Date: Mon Apr 16 12:32:45 2012
New Revision: 154836
URL: http://llvm.org/viewvc/llvm-project?rev=154836&view=rev
Log:
Adding in-place modifiers to FileSpec ; Making target installation support rsyncing entire bundles over to the remote end
Modified:
lldb/branches/lldb-platform-work/include/lldb/Host/FileSpec.h
lldb/branches/lldb-platform-work/source/Commands/CommandObjectPlatform.cpp
lldb/branches/lldb-platform-work/source/Host/common/FileSpec.cpp
Modified: lldb/branches/lldb-platform-work/include/lldb/Host/FileSpec.h
URL: http://llvm.org/viewvc/llvm-project/lldb/branches/lldb-platform-work/include/lldb/Host/FileSpec.h?rev=154836&r1=154835&r2=154836&view=diff
==============================================================================
--- lldb/branches/lldb-platform-work/include/lldb/Host/FileSpec.h (original)
+++ lldb/branches/lldb-platform-work/include/lldb/Host/FileSpec.h Mon Apr 16 12:32:45 2012
@@ -564,9 +564,15 @@
Resolve (const char *src_path, char *dst_path, size_t dst_len);
FileSpec
- AppendPathComponent (const char *new_path);
+ CopyByAppendingPathComponent (const char *new_path);
FileSpec
+ CopyByRemovingLastPathComponent ();
+
+ void
+ AppendPathComponent (const char *new_path);
+
+ void
RemoveLastPathComponent ();
const char*
Modified: lldb/branches/lldb-platform-work/source/Commands/CommandObjectPlatform.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/branches/lldb-platform-work/source/Commands/CommandObjectPlatform.cpp?rev=154836&r1=154835&r2=154836&view=diff
==============================================================================
--- lldb/branches/lldb-platform-work/source/Commands/CommandObjectPlatform.cpp (original)
+++ lldb/branches/lldb-platform-work/source/Commands/CommandObjectPlatform.cpp Mon Apr 16 12:32:45 2012
@@ -1611,7 +1611,7 @@
{
// make the new directory and get in there
FileSpec new_directory(rc_baton->destination.c_str(),false);
- new_directory = new_directory.AppendPathComponent(spec.GetLastPathComponent());
+ new_directory.AppendPathComponent(spec.GetLastPathComponent());
uint32_t errcode = rc_baton->platform_sp->MakeDirectory(new_directory, 0777);
std::string new_directory_path;
new_directory.GetPath(new_directory_path);
@@ -1689,6 +1689,7 @@
result.SetStatus(eReturnStatusFailed);
return false;
}
+ // TODO: move the bulk of this code over to the platform itself
std::string local_thing(args.GetArgumentAtIndex(0));
std::string remote_sandbox(args.GetArgumentAtIndex(1));
FileSpec source(local_thing.c_str(), true);
@@ -1708,8 +1709,18 @@
FileSpec::FileType source_type(source.GetFileType());
if (source_type == FileSpec::eFileTypeDirectory)
{
+ if (platform_sp->GetSupportsRSync())
+ {
+ FileSpec remote_folder(remote_sandbox.c_str(), false);
+ Error rsync_err = platform_sp->PutFile(source, remote_folder);
+ if (rsync_err.Success())
+ {
+ result.SetStatus(eReturnStatusSuccessFinishResult);
+ return result.Succeeded();
+ }
+ }
FileSpec remote_folder(remote_sandbox.c_str(), false);
- remote_folder = remote_folder.AppendPathComponent(source.GetLastPathComponent());
+ remote_folder.AppendPathComponent(source.GetLastPathComponent());
// TODO: default permissions are bad
uint32_t errcode = platform_sp->MakeDirectory(remote_folder, 0777);
if (errcode != 0)
Modified: lldb/branches/lldb-platform-work/source/Host/common/FileSpec.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/branches/lldb-platform-work/source/Host/common/FileSpec.cpp?rev=154836&r1=154835&r2=154836&view=diff
==============================================================================
--- lldb/branches/lldb-platform-work/source/Host/common/FileSpec.cpp (original)
+++ lldb/branches/lldb-platform-work/source/Host/common/FileSpec.cpp Mon Apr 16 12:32:45 2012
@@ -979,7 +979,7 @@
}
FileSpec
-FileSpec::AppendPathComponent (const char *new_path)
+FileSpec::CopyByAppendingPathComponent (const char *new_path)
{
const bool resolve = false;
if (m_filename.IsEmpty() && m_directory.IsEmpty())
@@ -995,7 +995,7 @@
}
FileSpec
-FileSpec::RemoveLastPathComponent ()
+FileSpec::CopyByRemovingLastPathComponent ()
{
const bool resolve = false;
if (m_filename.IsEmpty() && m_directory.IsEmpty())
@@ -1055,3 +1055,60 @@
}
return m_filename.GetCString();
}
+
+void
+FileSpec::AppendPathComponent (const char *new_path)
+{
+ const bool resolve = false;
+ if (m_filename.IsEmpty() && m_directory.IsEmpty())
+ {
+ SetFile(new_path,resolve);
+ return;
+ }
+ StreamString stream;
+ if (m_filename.IsEmpty())
+ stream.Printf("%s/%s",m_directory.GetCString(),new_path);
+ else if (m_directory.IsEmpty())
+ stream.Printf("%s/%s",m_filename.GetCString(),new_path);
+ else
+ stream.Printf("%s/%s/%s",m_directory.GetCString(), m_filename.GetCString(),new_path);
+ SetFile(stream.GetData(), resolve);
+}
+
+void
+FileSpec::RemoveLastPathComponent ()
+{
+ const bool resolve = false;
+ if (m_filename.IsEmpty() && m_directory.IsEmpty())
+ {
+ SetFile("",resolve);
+ return;
+ }
+ if (m_directory.IsEmpty())
+ {
+ SetFile("",resolve);
+ return;
+ }
+ if (m_filename.IsEmpty())
+ {
+ const char* dir_cstr = m_directory.GetCString();
+ const char* last_slash_ptr = ::strrchr(dir_cstr, '/');
+
+ // check for obvious cases before doing the full thing
+ if (!last_slash_ptr)
+ {
+ SetFile("",resolve);
+ return;
+ }
+ if (last_slash_ptr == dir_cstr)
+ {
+ SetFile("/",resolve);
+ return;
+ }
+ size_t last_slash_pos = last_slash_ptr - dir_cstr+1;
+ ConstString new_path(dir_cstr,last_slash_pos);
+ SetFile(new_path.GetCString(),resolve);
+ }
+ else
+ SetFile(m_directory.GetCString(),resolve);
+}
More information about the lldb-commits
mailing list