Esempio n. 1
0
static char* GetPath_XDG_CONFIG_HOME(void)
{
	char* path = NULL;
#if defined(WIN32) && !defined(_UWP)
	path = calloc(MAX_PATH, sizeof(char));

	if (!path)
		return NULL;

	if (FAILED(SHGetFolderPathA(0, CSIDL_APPDATA, NULL, SHGFP_TYPE_CURRENT, path)))
	{
		free(path);
		return NULL;
	}

#elif defined(__IOS__)
	path = GetCombinedPath(GetPath_HOME(), ".freerdp");
#else
	char* home = NULL;
	/**
	 * There is a single base directory relative to which user-specific configuration files should be written.
	 * This directory is defined by the environment variable $XDG_CONFIG_HOME.
	 *
	 * $XDG_CONFIG_HOME defines the base directory relative to which user specific configuration files should be stored.
	 * If $XDG_CONFIG_HOME is either not set or empty, a default equal to $HOME/.config should be used.
	 */
	path = GetEnvAlloc("XDG_CONFIG_HOME");

	if (path)
		return path;

	home = GetPath_HOME();

	if (!home)
		home = GetPath_TEMP();

	if (!home)
		return NULL;

	path = (char*) malloc(strlen(home) + strlen("/.config") + 1);

	if (!path)
	{
		free(home);
		return NULL;
	}

	sprintf(path, "%s%s", home, "/.config");
	free(home);
#endif
	return path;
}
Esempio n. 2
0
char* GetPath_XDG_DATA_HOME()
{
	char* path = NULL;
	char* home = NULL;

	/**
	 * There is a single base directory relative to which user-specific data files should be written.
	 * This directory is defined by the environment variable $XDG_DATA_HOME.
	 *
	 * $XDG_DATA_HOME defines the base directory relative to which user specific data files should be stored.
	 * If $XDG_DATA_HOME is either not set or empty, a default equal to $HOME/.local/share should be used.
	 */

	path = GetEnvAlloc("XDG_DATA_HOME");

	if (path)
		return path;

	home = GetPath_HOME();

	path = (char*) malloc(strlen(home) + strlen("/.local/share") + 1);
	sprintf(path, "%s%s", home, "/.local/share");

	free(home);

	return path;
}
Esempio n. 3
0
static char* GetPath_XDG_CACHE_HOME(void)
{
	char* path = NULL;
	char* home = NULL;
#if defined(WIN32)
	home = GetPath_XDG_RUNTIME_DIR();

	if (home)
	{
		path = GetCombinedPath(home, "cache");

		if (!PathFileExistsA(path))
			if (!CreateDirectoryA(path, NULL))
				path = NULL;
	}

	free(home);
#else
	/**
	 * There is a single base directory relative to which user-specific non-essential (cached) data should be written.
	 * This directory is defined by the environment variable $XDG_CACHE_HOME.
	 *
	 * $XDG_CACHE_HOME defines the base directory relative to which user specific non-essential data files should be stored.
	 * If $XDG_CACHE_HOME is either not set or empty, a default equal to $HOME/.cache should be used.
	 */
	path = GetEnvAlloc("XDG_CACHE_HOME");

	if (path)
		return path;

	home = GetPath_HOME();

	if (!home)
		return NULL;

	path = (char*) malloc(strlen(home) + strlen("/.cache") + 1);

	if (!path)
	{
		free(home);
		return NULL;
	}

	sprintf(path, "%s%s", home, "/.cache");
	free(home);
#endif
	return path;
}
Esempio n. 4
0
char* GetKnownPath(int id)
{
	char* path = NULL;

	switch (id)
	{
		case KNOWN_PATH_HOME:
			path = GetPath_HOME();
			break;

		case KNOWN_PATH_TEMP:
			path = GetPath_TEMP();

			break;

		case KNOWN_PATH_XDG_DATA_HOME:
			path = GetPath_XDG_DATA_HOME();
			break;

		case KNOWN_PATH_XDG_CONFIG_HOME:
			path = GetPath_XDG_CONFIG_HOME();
			break;

		case KNOWN_PATH_XDG_CACHE_HOME:
			path = GetPath_XDG_CACHE_HOME();
			break;

		case KNOWN_PATH_XDG_RUNTIME_DIR:
			path = GetPath_XDG_RUNTIME_DIR();
			break;

		default:
			path = NULL;
			break;
	}

	return path;
}