From 8420578671cd28eb5b040650664d23091b95ea78 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mart=C3=ADn=20Lucas=20Golini?= Date: Fri, 28 Dec 2012 03:33:43 -0300 Subject: [PATCH] A couple of fixes in Sys::GetConfigPath. --- projects/linux/ee.creator.user | 4 ++-- src/eepp/system/sys.cpp | 19 ++++++++++--------- 2 files changed, 12 insertions(+), 11 deletions(-) diff --git a/projects/linux/ee.creator.user b/projects/linux/ee.creator.user index c98807976..1359a96ec 100644 --- a/projects/linux/ee.creator.user +++ b/projects/linux/ee.creator.user @@ -1,6 +1,6 @@ - + ProjectExplorer.Project.ActiveTarget @@ -97,7 +97,7 @@ false - -j4 config=release eepp-test + -j4 -e config=release eepp-test true Make diff --git a/src/eepp/system/sys.cpp b/src/eepp/system/sys.cpp index 8518754aa..7ea4f72d6 100644 --- a/src/eepp/system/sys.cpp +++ b/src/eepp/system/sys.cpp @@ -494,18 +494,19 @@ std::string Sys::GetDateTimeStr() { #endif } +#define EE_MAX_CFG_PATH_LEN 1024 std::string Sys::GetConfigPath( std::string appname ) { - char path[256]; + char path[EE_MAX_CFG_PATH_LEN]; #if EE_PLATFORM == EE_PLATFORM_WIN #ifdef EE_COMPILER_MSVC char * ppath; - size_t ssize = 256; + size_t ssize = EE_MAX_CFG_PATH_LEN; _dupenv_s( &ppath, &ssize, "APPDATA" ); - StrCopy( path, ppath, 256 ); + String::StrCopy( path, ppath, EE_MAX_CFG_PATH_LEN ); free( ppath ); @@ -518,7 +519,7 @@ std::string Sys::GetConfigPath( std::string appname ) { if( !home ) return std::string(); - _snprintf(path, 256, "%s\\%s", home, appname.c_str() ); + _snprintf(path, EE_MAX_CFG_PATH_LEN, "%s\\%s", home, appname.c_str() ); #endif #elif EE_PLATFORM == EE_PLATFORM_MACOSX @@ -528,7 +529,7 @@ std::string Sys::GetConfigPath( std::string appname ) { return std::string(); } - snprintf(path, 256, "%s/Library/Application Support/%s", home, appname.c_str() ); + snprintf(path, EE_MAX_CFG_PATH_LEN, "%s/Library/Application Support/%s", home, appname.c_str() ); #elif EE_PLATFORM == EE_PLATFORM_HAIKU char *home = getenv("HOME"); @@ -536,12 +537,12 @@ std::string Sys::GetConfigPath( std::string appname ) { return std::string(); } - snprintf(path, 256, "%s/config/settings/%s", home, appname.c_str() ); + snprintf(path, EE_MAX_CFG_PATH_LEN, "%s/config/settings/%s", home, appname.c_str() ); #elif EE_PLATFORM == EE_PLATFORM_LINUX || EE_PLATFORM == EE_PLATFORM_BSD || EE_PLATFORM == EE_PLATFORM_SOLARIS char * config = getenv("XDG_CONFIG_HOME"); if ( NULL != config ) { - String::StrCopy( path, config, 256 ); + snprintf(path, EE_MAX_CFG_PATH_LEN, "%s/%s", config, appname.c_str() ); } else { char *home = getenv("HOME"); @@ -549,7 +550,7 @@ std::string Sys::GetConfigPath( std::string appname ) { return std::string(); } - snprintf(path, 256, "%s/.config/%s", home, appname.c_str() ); + snprintf(path, EE_MAX_CFG_PATH_LEN, "%s/.config/%s", home, appname.c_str() ); } #elif EE_PLATFORM == EE_PLATFORM_IOS return GetProcessPath() + "config"; @@ -567,7 +568,7 @@ std::string Sys::GetConfigPath( std::string appname ) { return std::string(); } - snprintf(path, 256, "%s/.%s", home, appname.c_str() ); + snprintf(path, EE_MAX_CFG_PATH_LEN, "%s/.%s", home, appname.c_str() ); #endif return std::string( path );