aboutsummaryrefslogtreecommitdiff
path: root/source/API/SBFileSpec.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'source/API/SBFileSpec.cpp')
-rw-r--r--source/API/SBFileSpec.cpp30
1 files changed, 22 insertions, 8 deletions
diff --git a/source/API/SBFileSpec.cpp b/source/API/SBFileSpec.cpp
index 4fd2866c9b05..8d63fc587d81 100644
--- a/source/API/SBFileSpec.cpp
+++ b/source/API/SBFileSpec.cpp
@@ -7,6 +7,7 @@
//
//===----------------------------------------------------------------------===//
+#include <inttypes.h> // PRIu64
#include <limits.h>
#include "lldb/API/SBFileSpec.h"
@@ -15,6 +16,8 @@
#include "lldb/Core/Log.h"
#include "lldb/Core/Stream.h"
+#include "llvm/ADT/SmallString.h"
+
using namespace lldb;
using namespace lldb_private;
@@ -35,7 +38,7 @@ SBFileSpec::SBFileSpec (const lldb_private::FileSpec& fspec) :
{
}
-// Deprected!!!
+// Deprecated!!!
SBFileSpec::SBFileSpec (const char *path) :
m_opaque_ap(new FileSpec (path, true))
{
@@ -72,7 +75,9 @@ SBFileSpec::Exists () const
bool result = m_opaque_ap->Exists();
if (log)
- log->Printf ("SBFileSpec(%p)::Exists () => %s", m_opaque_ap.get(), (result ? "true" : "false"));
+ log->Printf ("SBFileSpec(%p)::Exists () => %s",
+ static_cast<void*>(m_opaque_ap.get()),
+ (result ? "true" : "false"));
return result;
}
@@ -86,7 +91,11 @@ SBFileSpec::ResolveExecutableLocation ()
int
SBFileSpec::ResolvePath (const char *src_path, char *dst_path, size_t dst_len)
{
- return lldb_private::FileSpec::Resolve (src_path, dst_path, dst_len);
+ llvm::SmallString<64> result(src_path);
+ lldb_private::FileSpec::Resolve (result);
+ size_t result_length = std::min(dst_len-1, result.size());
+ ::strncpy(dst_path, result.c_str(), result_length + 1);
+ return result_length;
}
const char *
@@ -98,9 +107,11 @@ SBFileSpec::GetFilename() const
if (log)
{
if (s)
- log->Printf ("SBFileSpec(%p)::GetFilename () => \"%s\"", m_opaque_ap.get(), s);
+ log->Printf ("SBFileSpec(%p)::GetFilename () => \"%s\"",
+ static_cast<void*>(m_opaque_ap.get()), s);
else
- log->Printf ("SBFileSpec(%p)::GetFilename () => NULL", m_opaque_ap.get());
+ log->Printf ("SBFileSpec(%p)::GetFilename () => NULL",
+ static_cast<void*>(m_opaque_ap.get()));
}
return s;
@@ -114,9 +125,11 @@ SBFileSpec::GetDirectory() const
if (log)
{
if (s)
- log->Printf ("SBFileSpec(%p)::GetDirectory () => \"%s\"", m_opaque_ap.get(), s);
+ log->Printf ("SBFileSpec(%p)::GetDirectory () => \"%s\"",
+ static_cast<void*>(m_opaque_ap.get()), s);
else
- log->Printf ("SBFileSpec(%p)::GetDirectory () => NULL", m_opaque_ap.get());
+ log->Printf ("SBFileSpec(%p)::GetDirectory () => NULL",
+ static_cast<void*>(m_opaque_ap.get()));
}
return s;
}
@@ -148,7 +161,8 @@ SBFileSpec::GetPath (char *dst_path, size_t dst_len) const
if (log)
log->Printf ("SBFileSpec(%p)::GetPath (dst_path=\"%.*s\", dst_len=%" PRIu64 ") => %u",
- m_opaque_ap.get(), result, dst_path, (uint64_t)dst_len, result);
+ static_cast<void*>(m_opaque_ap.get()), result, dst_path,
+ static_cast<uint64_t>(dst_len), result);
if (result == 0 && dst_path && dst_len > 0)
*dst_path = '\0';