diff options
author | Enrico Granata <granata.enrico@gmail.com> | 2011-10-17 21:45:27 +0000 |
---|---|---|
committer | Enrico Granata <granata.enrico@gmail.com> | 2011-10-17 21:45:27 +0000 |
commit | a9dbf4325e9b97ca4c68baf4d05fad55bd194332 (patch) | |
tree | fc59812edc526ec91c28e8fbddc6ca5c32e1833b /lldb/source/Host/common/FileSpec.cpp | |
parent | a5748e22e2c997ae5fbe4aa3b9170e7a12375e26 (diff) | |
download | bcm5719-llvm-a9dbf4325e9b97ca4c68baf4d05fad55bd194332.tar.gz bcm5719-llvm-a9dbf4325e9b97ca4c68baf4d05fad55bd194332.zip |
this patch introduces a new command script import command which takes as input a filename for a Python script and imports the module contained in that file. the containing directory is added to the Python path such that dependencies are honored. also, the module may contain an __lldb_init_module(debugger,dict) function, which gets called after importing, and which can somehow initialize the module's interaction with lldb
llvm-svn: 142283
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 |