]> Creatis software - bbtk.git/blobdiff - kernel/src/bbtkUtilities.cxx
Forgot this one
[bbtk.git] / kernel / src / bbtkUtilities.cxx
index 21fa9479f3ceb892e86e48b51a177caa9a57d885..7c02a604027393f9c4075cde07bd0f05c530a2ec 100644 (file)
@@ -2,8 +2,8 @@
   Program:   bbtk
   Module:    $RCSfile: bbtkUtilities.cxx,v $
   Language:  C++
-  Date:      $Date: 2009/01/27 14:22:57 $
-  Version:   $Revision: 1.11 $
+  Date:      $Date: 2009/10/05 22:44:48 $
+  Version:   $Revision: 1.14 $
 =========================================================================*/
 
 /* ---------------------------------------------------------------------
 #include "bbtkUtilities.h"
 #include "bbtkMessageManager.h"
 
+#if defined(MACOSX) // assume this is OSX 
+# include <sys/param.h>
+# include <mach-o/dyld.h> // _NSGetExecutablePath : must add -framework CoreFoundation to link line 
+# include <string.h>
+# ifndef PATH_MAX
+#  define PATH_MAX MAXPATHLEN
+# endif
+#endif // MACOSX
+
+#ifndef PATH_MAX // If not defined yet : do it 
+#  define PATH_MAX 2048
+#endif 
 
 namespace bbtk
 {
@@ -254,7 +265,8 @@ namespace bbtk
   std::string Utilities::MakeLibnameFromPath(std::string path, std::string pkgname)
   {
     std::string libname = path;
-    char c = path[path.size()-1];    
+       if(path.size()>0){
+               char c = path[path.size()-1];    
 #if defined(__GNUC__)
        if (c != '/')
           libname += "/libbb";
@@ -268,11 +280,15 @@ namespace bbtk
 #endif 
          
 #elif defined(_WIN32)
-       if (c != '\\')
-          libname = path+"\\bb";
+       if (c != '\\') 
+          libname += "\\bb";
+       else
+          libname += "bb";
        libname += pkgname;
        libname += ".dll";
 #endif
+       }
+    
     return libname;    
   }
 
@@ -281,23 +297,26 @@ namespace bbtk
   std::string Utilities::MakePkgnameFromPath(std::string path, std::string pkgname, bool addExt)
   {
     std::string libname = path;
-    char c = path[path.size()-1];
-    if (c != '/' && c != '\\')
-    {
-       libname +=  ConfigurationFile::GetInstance().Get_file_separator ();
-    }
-    libname += pkgname;
-    if (addExt)
-    {
-       int l = libname.size();
-       if (l>4)
-       {
-          if (libname.substr(l-4, 4) != ".bbs")
-          {
-               libname = libname + ".bbs";
-          }
-       }
-    }
+       if(path.size()>0){
+               char c = path[path.size()-1];
+               if (c != '/' && c != '\\')
+               {
+                  libname +=  ConfigurationFile::GetInstance().Get_file_separator ();
+               }
+               libname += pkgname;
+               if (addExt)
+               {
+                  int l = libname.size();
+                  if (l>4)
+                  {
+                         if (libname.substr(l-4, 4) != ".bbs")
+                         {
+                                  libname = libname + ".bbs";
+                         }
+                  }
+               }
+       }
+    
     return libname;
   }
   // =======================================================================