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
{
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";
#endif
#elif defined(_WIN32)
- if (c != '\\')
- libname = path+"\\bb";
+ if (c != '\\')
+ libname += "\\bb";
+ else
+ libname += "bb";
libname += pkgname;
libname += ".dll";
#endif
+ }
+
return libname;
}
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;
}
// =======================================================================