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
diff --git a/lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationServerCommon.cpp b/lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationServerCommon.cpp
index c61d9f4..18e8118 100644
--- a/lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationServerCommon.cpp
+++ b/lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationServerCommon.cpp
@@ -584,8 +584,8 @@
             {
                 mode_t mode = packet.GetHexMaxU32(false, 0600);
                 Error error;
-                const FileSpec path_spec(path.c_str(), true);
-                int fd = ::open (path_spec.GetPath().c_str(), flags, mode);
+                const FileSpec path_spec{path, true};
+                int fd = ::open(path_spec.GetCString(), flags, mode);
                 const int save_errno = fd == -1 ? errno : 0;
                 StreamString response;
                 response.PutChar('F');
@@ -734,7 +734,7 @@
     if (!path.empty())
     {
         Error error;
-        const uint32_t mode = File::GetPermissions(path.c_str(), error);
+        const uint32_t mode = File::GetPermissions(FileSpec{path, true}, error);
         StreamString response;
         response.Printf("F%u", mode);
         if (mode == 0 || error.Fail())
@@ -773,7 +773,7 @@
     packet.GetHexByteStringTerminatedBy(dst, ',');
     packet.GetChar(); // Skip ',' char
     packet.GetHexByteString(src);
-    Error error = FileSystem::Symlink(src.c_str(), dst.c_str());
+    Error error = FileSystem::Symlink(FileSpec{src, true}, FileSpec{dst, false});
     StreamString response;
     response.Printf("F%u,%u", error.GetError(), error.GetError());
     return SendPacketNoLock(response.GetData(), response.GetSize());
@@ -785,7 +785,7 @@
     packet.SetFilePos(::strlen("vFile:unlink:"));
     std::string path;
     packet.GetHexByteString(path);
-    Error error = FileSystem::Unlink(path.c_str());
+    Error error = FileSystem::Unlink(FileSpec{path, true});
     StreamString response;
     response.Printf("F%u,%u", error.GetError(), error.GetError());
     return SendPacketNoLock(response.GetData(), response.GetSize());
@@ -810,7 +810,7 @@
             int status, signo;
             std::string output;
             Error err = Host::RunShellCommand(path.c_str(),
-                                              working_dir.empty() ? NULL : working_dir.c_str(),
+                                              FileSpec{working_dir, true},
                                               &status, &signo, &output, timeout);
             StreamGDBRemote response;
             if (err.Fail())
@@ -875,8 +875,8 @@
     {
         std::string path;
         packet.GetHexByteString(path);
-        Error error = FileSystem::MakeDirectory(path.c_str(), mode);
-        
+        Error error = FileSystem::MakeDirectory(FileSpec{path, false}, mode);
+
         StreamGDBRemote response;
         response.Printf("F%u", error.GetError());
 
@@ -895,7 +895,7 @@
     {
         std::string path;
         packet.GetHexByteString(path);
-        Error error = FileSystem::SetFilePermissions(path.c_str(), mode);
+        Error error = FileSystem::SetFilePermissions(FileSpec{path, true}, mode);
 
         StreamGDBRemote response;
         response.Printf("F%u", error.GetError());
@@ -968,7 +968,7 @@
     packet.GetHexByteString(path);
     const bool read = false;
     const bool write = true;
-    if (file_action.Open(STDIN_FILENO, path.c_str(), read, write))
+    if (file_action.Open(STDIN_FILENO, FileSpec{path, false}, read, write))
     {
         m_process_launch_info.AppendFileAction(file_action);
         return SendOKResponse ();
@@ -985,7 +985,7 @@
     packet.GetHexByteString(path);
     const bool read = true;
     const bool write = false;
-    if (file_action.Open(STDOUT_FILENO, path.c_str(), read, write))
+    if (file_action.Open(STDOUT_FILENO, FileSpec{path, false}, read, write))
     {
         m_process_launch_info.AppendFileAction(file_action);
         return SendOKResponse ();
@@ -1002,7 +1002,7 @@
     packet.GetHexByteString(path);
     const bool read = true;
     const bool write = false;
-    if (file_action.Open(STDERR_FILENO, path.c_str(), read, write))
+    if (file_action.Open(STDERR_FILENO, FileSpec{path, false}, read, write))
     {
         m_process_launch_info.AppendFileAction(file_action);
         return SendOKResponse ();
@@ -1217,7 +1217,7 @@
     response.PutChar(';');
 
     response.PutCString("file_path:");
-    response.PutCStringAsRawHex8(module_path_spec.GetPath().c_str());
+    response.PutCStringAsRawHex8(module_path_spec.GetCString());
     response.PutChar(';');
     response.PutCString("file_offset:");
     response.PutHex64(file_offset);
@@ -1241,7 +1241,7 @@
                      proc_info.GetEffectiveUserID(),
                      proc_info.GetEffectiveGroupID());
     response.PutCString ("name:");
-    response.PutCStringAsRawHex8(proc_info.GetExecutableFile().GetPath().c_str());
+    response.PutCStringAsRawHex8(proc_info.GetExecutableFile().GetCString());
     response.PutChar(';');
     const ArchSpec &proc_arch = proc_info.GetArchitecture();
     if (proc_arch.IsValid())