Ejemplo n.º 1
0
		inline std::wstring getFolder() {
			TCHAR buf[MAX_PATH+1];
			if (!_SHGetSpecialFolderPath(NULL, buf, CSIDL_LOCAL_APPDATA, FALSE)) {
				return _T("") + error::lookup::last_error();
			}
			return buf;
		}
Ejemplo n.º 2
0
string HomeDirPlugin::defaultPath()
{
    string s;
#ifndef WIN32
    struct passwd *pwd = getpwuid(getuid());
    if (pwd){
        s = pwd->pw_dir;
    }else{
        log(L_ERROR, "Can't get pwd");
    }
    if (s[s.size() - 1] != '/')
        s += '/';
#ifdef USE_KDE
    char *kdehome = getenv("KDEHOME");
    if (kdehome){
        s = kdehome;
    }else{
        s += ".kde/";
    }
    if (s.length() == 0) s += '/';
    if (s[s.length()-1] != '/') s += '/';
    s += "share/apps/sim";
#else
    s += ".sim";
#endif
#else
    char szPath[512];
    HINSTANCE hLib = LoadLibraryA("Shell32.dll");
    if (hLib != NULL)
        (DWORD&)_SHGetSpecialFolderPath = (DWORD)GetProcAddress(hLib,"SHGetSpecialFolderPathA");
    if (_SHGetSpecialFolderPath && _SHGetSpecialFolderPath(NULL, szPath, CSIDL_APPDATA, true)){
        s = szPath;
        if (s.length()  == 0) s = "c:\\";
        if (s[s.length() - 1] != '\\') s += '\\';
        s += "sim";
    }else{
        s = app_file("");
    }
#endif
    return s;
}
Ejemplo n.º 3
0
	std::string getFolder(std::string key) {
		std::string default_value = getBasePath().string();
		if (key == "certificate-path") {
			default_value = CERT_FOLDER;
		} else if (key == "module-path") {
			default_value = MODULE_FOLDER;
		} else if (key == "web-path") {
			default_value = WEB_FOLDER;
		} else if (key == "scripts") {
			default_value = SCRIPTS_FOLDER;
		} else if (key == CACHE_FOLDER_KEY) {
			default_value = DEFAULT_CACHE_PATH;
		} else if (key == CRASH_ARCHIVE_FOLDER_KEY) {
			default_value = CRASH_ARCHIVE_FOLDER;
		} else if (key == "base-path") {
			default_value = getBasePath().string();
		} else if (key == "temp") {
			default_value = getTempPath().string();
		} else if (key == "shared-path" || key == "base-path" || key == "exe-path") {
			default_value = getBasePath().string();
		}
#ifdef WIN32
		else if (key == "common-appdata") {
			wchar_t buf[MAX_PATH + 1];
			if (_SHGetSpecialFolderPath(NULL, buf, CSIDL_COMMON_APPDATA, FALSE))
				default_value = utf8::cvt<std::string>(buf);
			else
				default_value = getBasePath().string();
		}
#else
		else if (key == "etc") {
			default_value = "/etc";
		}
#endif
		return default_value;
	}