MCPcopy Create free account
hub / github.com/SpartanJ/eepp / getConfigPath

Method getConfigPath

src/eepp/system/sys.cpp:760–836  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

758
759#define EE_MAX_CFG_PATH_LEN 1024
760std::string Sys::getConfigPath( const std::string& appname ) {
761 char path[EE_MAX_CFG_PATH_LEN];
762
763#if EE_PLATFORM == EE_PLATFORM_WIN
764#ifdef EE_COMPILER_MSVC
765
766 char* ppath;
767 size_t ssize = EE_MAX_CFG_PATH_LEN;
768
769 _dupenv_s( &ppath, &ssize, "APPDATA" );
770
771 _snprintf( path, EE_MAX_CFG_PATH_LEN, "%s\\%s", ppath, appname.c_str() );
772
773 free( ppath );
774
775 if ( !ssize )
776 return std::string();
777
778#else
779 char* home = getenv( "APPDATA" );
780
781 if ( !home )
782 return std::string();
783
784 _snprintf( path, EE_MAX_CFG_PATH_LEN, "%s\\%s", home, appname.c_str() );
785
786#endif
787#elif EE_PLATFORM == EE_PLATFORM_MACOS
788 char* home = getenv( "HOME" );
789
790 if ( NULL == home ) {
791 return std::string();
792 }
793
794 snprintf( path, EE_MAX_CFG_PATH_LEN, "%s/Library/Application Support/%s", home,
795 appname.c_str() );
796#elif EE_PLATFORM == EE_PLATFORM_HAIKU
797 char* home = getenv( "HOME" );
798
799 if ( NULL == home ) {
800 return std::string();
801 }
802
803 snprintf( path, EE_MAX_CFG_PATH_LEN, "%s/config/settings/%s", home, appname.c_str() );
804#elif EE_PLATFORM == EE_PLATFORM_LINUX || EE_PLATFORM == EE_PLATFORM_BSD || \
805 EE_PLATFORM == EE_PLATFORM_SOLARIS
806 char* config = getenv( "XDG_CONFIG_HOME" );
807
808 if ( NULL != config ) {
809 snprintf( path, EE_MAX_CFG_PATH_LEN, "%s/%s", config, appname.c_str() );
810 } else {
811 char* home = getenv( "HOME" );
812
813 if ( NULL == home ) {
814 return std::string();
815 }
816
817 snprintf( path, EE_MAX_CFG_PATH_LEN, "%s/.config/%s", home, appname.c_str() );

Callers

nothing calls this directly

Calls 4

freeFunction · 0.85
c_strMethod · 0.80
getPlatformHelperMethod · 0.80

Tested by

no test coverage detected