diff options
Diffstat (limited to 'lldb/source/Host/common/FileSpec.cpp')
-rw-r--r-- | lldb/source/Host/common/FileSpec.cpp | 31 |
1 files changed, 30 insertions, 1 deletions
diff --git a/lldb/source/Host/common/FileSpec.cpp b/lldb/source/Host/common/FileSpec.cpp index 5e034db6571..35e12ebdb57 100644 --- a/lldb/source/Host/common/FileSpec.cpp +++ b/lldb/source/Host/common/FileSpec.cpp @@ -699,10 +699,39 @@ FileSpec::GetPath(char *path, size_t path_max_len) const return ::snprintf (path, path_max_len, "%s", filename); } } - path[0] = '\0'; + if (path) + path[0] = '\0'; return 0; } +ConstString +FileSpec::GetFileNameExtension () const +{ + const char *filename = m_filename.GetCString(); + if (filename == NULL) + return ConstString(); + + char* dot_pos = strrchr(filename, '.'); + if (dot_pos == NULL) + return ConstString(); + + return ConstString(dot_pos+1); +} + +ConstString +FileSpec::GetFileNameStrippingExtension () const +{ + const char *filename = m_filename.GetCString(); + if (filename == NULL) + return ConstString(); + + char* dot_pos = strrchr(filename, '.'); + if (dot_pos == NULL) + return m_filename; + + return ConstString(filename, dot_pos-filename); +} + //------------------------------------------------------------------ // Returns a shared pointer to a data buffer that contains all or // part of the contents of a file. The data is memory mapped and |