| 758 | |
| 759 | #define EE_MAX_CFG_PATH_LEN 1024 |
| 760 | std::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() ); |
nothing calls this directly
no test coverage detected