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

git-svn-id: https://llvm.org/svn/llvm-project/llvdb/trunk@142283 91177308-0d34-0410-b5e6-96231b3b80d8
diff --git a/source/Host/common/FileSpec.cpp b/source/Host/common/FileSpec.cpp
index 5e034db..35e12eb 100644
--- a/source/Host/common/FileSpec.cpp
+++ b/source/Host/common/FileSpec.cpp
@@ -699,10 +699,39 @@
             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