Index: include/lldb/Host/FileSpec.h =================================================================== --- include/lldb/Host/FileSpec.h +++ include/lldb/Host/FileSpec.h @@ -638,6 +638,7 @@ static void Normalize(llvm::SmallVectorImpl &path, PathSyntax syntax = ePathSyntaxHostNative); static void DeNormalize(llvm::SmallVectorImpl &path, PathSyntax syntax = ePathSyntaxHostNative); + char GetPathSeparator() const; //------------------------------------------------------------------ /// Run through the input string, replaying the effect of any ".." and produce Index: source/Host/common/FileSpec.cpp =================================================================== --- source/Host/common/FileSpec.cpp +++ source/Host/common/FileSpec.cpp @@ -276,6 +276,16 @@ std::replace(path.begin(), path.end(), '/', '\\'); } +char +FileSpec::GetPathSeparator() const +{ + if (m_syntax == ePathSyntaxPosix || + (m_syntax == ePathSyntaxHostNative && FileSystem::GetNativePathSyntax() == ePathSyntaxPosix)) + return '/'; + + return '\\'; +} + //------------------------------------------------------------------ // Update the contents of this object with a new path. The path will // be split up into a directory and filename and stored as uniqued @@ -613,11 +623,11 @@ { if (s) { - m_directory.Dump(s); - if ((m_filename || trailing_slash) && m_directory && - !m_directory.GetStringRef().endswith("/")) - s->PutChar('/'); - m_filename.Dump(s); + std::string path = GetPath(true); + + s->PutCString(path.c_str()); + if (trailing_slash && !m_filename) + s->PutChar(GetPathSeparator()); } } @@ -816,12 +826,23 @@ void FileSpec::GetPath(llvm::SmallVectorImpl &path, bool denormalize) const { - StreamString stream; - Dump(&stream, false); - path.append(stream.GetString().begin(), stream.GetString().end()); - Normalize(path, m_syntax); + if (m_directory) + { + llvm::StringRef dir(m_directory.AsCString()); + path.append(dir.begin(), dir.end()); + } + + if (m_filename) + { + if (m_directory && !m_directory.GetStringRef().endswith("/")) + path.push_back('/'); + llvm::StringRef file(m_filename.AsCString()); + path.append(file.begin(), file.end()); + } + if (denormalize && !path.empty()) DeNormalize(path, m_syntax); + std::string result(path.begin(), path.end()); } ConstString