X-Git-Url: https://git.creatis.insa-lyon.fr/pubgit/?a=blobdiff_plain;f=kernel%2Fsrc%2FbbtkUtilities.cxx;fp=kernel%2Fsrc%2FbbtkUtilities.cxx;h=def9fd96352228527a9b6a821e00157395cbbdb6;hb=4a7c20686ae0480a3c522db62ac9b01fdff030a5;hp=51724cd4b147cc862f47c7e89dd2cefc912ee20d;hpb=b7d6fdd0df18c14ba87b1954561c8ec6fb1e7a0a;p=bbtk.git diff --git a/kernel/src/bbtkUtilities.cxx b/kernel/src/bbtkUtilities.cxx index 51724cd..def9fd9 100644 --- a/kernel/src/bbtkUtilities.cxx +++ b/kernel/src/bbtkUtilities.cxx @@ -36,6 +36,7 @@ +#include "creaSystem.h" #include "bbtkUtilities.h" #include "bbtkMessageManager.h" @@ -618,6 +619,33 @@ namespace bbtk } //========================================================================= + + + +//===================================================================================== +/* http://forums.codeguru.com/showthread.php?336106-WCHAR*-to-CHAR* +|| ::DESCRIPTION:: +|| This function will convert a WCHAR string to a CHAR string. +|| +|| Param 1 :: Pointer to a buffer that will contain the converted string. Ensure this +|| buffer is large enough; if not, buffer overrun errors will occur. +|| Param 2 :: Constant pointer to a source WCHAR string to be converted to CHAR +*/ +/* +void wtoc(const WCHAR* Source,CHAR* Dest) +{ + int i = 0; + while(Source[i] != '\0') + { + Dest[i] = (CHAR)Source[i]; + ++i; + } // while +} +*/ + + + + //========================================================================= // From http://www.fltk.org/newsgroups.php?gfltk.general+v:22083 // @@ -645,7 +673,7 @@ namespace bbtk //2018-07-06 mingw64 wchar_t pname2[512]; long result = GetModuleFileName(NULL, pname2, pathsize); - int ret = wcstombs ( pname, pname2, sizeof(pname) ); + crea::System::wtoc(pname2,pname); // long result = GetModuleFileName(NULL, pname, pathsize); if (result > 0) { @@ -757,6 +785,8 @@ namespace bbtk { char name[PATH_MAX]; int err = get_app_path(name, PATH_MAX); +printf("EED bbtk Utilities::GetExecutablePath 1%s \n",name); + if (err) { try @@ -783,7 +813,9 @@ namespace bbtk std::string Utilities::GetEnvHome() { -#if defined(__GNUC__) +#if defined(_WIN32) + std::string strHome( getenv("USERPROFILE") ); +#elif defined(__GNUC__) std::string strHome; char *envHome=getenv("HOME"); if (envHome!=NULL) @@ -792,8 +824,6 @@ std::string Utilities::GetEnvHome() } else { strHome = "/var/www/testwtdbg/docroot"; } // if -#elif defined(_WIN32) - std::string strHome( getenv("USERPROFILE") ); #endif return strHome; }