From 0f31a1ef7ecf609d469ee5b34b3f0cb24ae3492d Mon Sep 17 00:00:00 2001 From: emaste Date: Tue, 3 Dec 2013 18:51:59 +0000 Subject: Import lldb as of SVN r196259 (git 3be86e5) (A number of files not required for the FreeBSD build have been removed.) Sponsored by: DARPA, AFRL --- source/Host/common/FileSpec.cpp | 32 +++++++++++++++++++++----------- 1 file changed, 21 insertions(+), 11 deletions(-) (limited to 'source/Host/common/FileSpec.cpp') diff --git a/source/Host/common/FileSpec.cpp b/source/Host/common/FileSpec.cpp index 33de198..48f1ac7 100644 --- a/source/Host/common/FileSpec.cpp +++ b/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 -- cgit v1.1