Fixed windows known path locations.
This commit is contained in:
parent
29de9b6d4e
commit
d1223d3799
@ -33,6 +33,12 @@
|
||||
|
||||
#include <winpr/path.h>
|
||||
|
||||
#if defined(WIN32)
|
||||
#include <Shlobj.h>
|
||||
#endif
|
||||
|
||||
static char* GetPath_XDG_CONFIG_HOME();
|
||||
|
||||
/**
|
||||
* SHGetKnownFolderPath function:
|
||||
* http://msdn.microsoft.com/en-us/library/windows/desktop/bb762188/
|
||||
@ -43,7 +49,7 @@
|
||||
* http://standards.freedesktop.org/basedir-spec/basedir-spec-latest.html
|
||||
*/
|
||||
|
||||
char* GetEnvAlloc(LPCSTR lpName)
|
||||
static char* GetEnvAlloc(LPCSTR lpName)
|
||||
{
|
||||
DWORD length;
|
||||
char* env = NULL;
|
||||
@ -62,7 +68,7 @@ char* GetEnvAlloc(LPCSTR lpName)
|
||||
return env;
|
||||
}
|
||||
|
||||
char* GetPath_HOME()
|
||||
static char* GetPath_HOME()
|
||||
{
|
||||
char* path = NULL;
|
||||
|
||||
@ -80,7 +86,7 @@ char* GetPath_HOME()
|
||||
return path;
|
||||
}
|
||||
|
||||
char* GetPath_TEMP()
|
||||
static char* GetPath_TEMP()
|
||||
{
|
||||
char* path = NULL;
|
||||
|
||||
@ -96,11 +102,14 @@ char* GetPath_TEMP()
|
||||
return path;
|
||||
}
|
||||
|
||||
char* GetPath_XDG_DATA_HOME()
|
||||
static char* GetPath_XDG_DATA_HOME()
|
||||
{
|
||||
char* path = NULL;
|
||||
char* home = NULL;
|
||||
|
||||
#if defined(WIN32)
|
||||
path = GetPath_XDG_CONFIG_HOME();
|
||||
#else
|
||||
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.
|
||||
@ -127,15 +136,28 @@ char* GetPath_XDG_DATA_HOME()
|
||||
sprintf(path, "%s%s", home, "/.local/share");
|
||||
|
||||
free(home);
|
||||
#endif
|
||||
|
||||
return path;
|
||||
}
|
||||
|
||||
char* GetPath_XDG_CONFIG_HOME()
|
||||
static char* GetPath_XDG_CONFIG_HOME()
|
||||
{
|
||||
char* path = NULL;
|
||||
char* home = NULL;
|
||||
|
||||
#if defined(WIN32)
|
||||
path = calloc(MAX_PATH, sizeof(char));
|
||||
if (!path)
|
||||
return NULL;
|
||||
|
||||
if (SHGetFolderPathA(0, CSIDL_APPDATA, NULL,
|
||||
SHGFP_TYPE_CURRENT, path) != S_OK)
|
||||
{
|
||||
free(path);
|
||||
return NULL;
|
||||
}
|
||||
#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.
|
||||
@ -166,15 +188,22 @@ char* GetPath_XDG_CONFIG_HOME()
|
||||
sprintf(path, "%s%s", home, "/.config");
|
||||
|
||||
free(home);
|
||||
#endif
|
||||
|
||||
return path;
|
||||
}
|
||||
|
||||
char* GetPath_XDG_CACHE_HOME()
|
||||
static char* GetPath_XDG_CACHE_HOME()
|
||||
{
|
||||
char* path = NULL;
|
||||
char* home = NULL;
|
||||
|
||||
#if defined(WIN32)
|
||||
home = GetPath_XDG_RUNTIME_DIR();
|
||||
|
||||
path = GetCombinedPath(home, "cache");
|
||||
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.
|
||||
@ -201,14 +230,26 @@ char* GetPath_XDG_CACHE_HOME()
|
||||
sprintf(path, "%s%s", home, "/.cache");
|
||||
|
||||
free(home);
|
||||
#endif
|
||||
|
||||
return path;
|
||||
}
|
||||
|
||||
char* GetPath_XDG_RUNTIME_DIR()
|
||||
static char* GetPath_XDG_RUNTIME_DIR()
|
||||
{
|
||||
char* path = NULL;
|
||||
#if defined(WIN32)
|
||||
path = calloc(MAX_PATH, sizeof(char));
|
||||
if (!path)
|
||||
return NULL;
|
||||
|
||||
if (SHGetFolderPathA(0, CSIDL_LOCAL_APPDATA, NULL,
|
||||
SHGFP_TYPE_CURRENT, path) != S_OK)
|
||||
{
|
||||
free(path);
|
||||
return NULL;
|
||||
}
|
||||
#else
|
||||
/**
|
||||
* There is a single base directory relative to which user-specific runtime files and other file objects should be placed.
|
||||
* This directory is defined by the environment variable $XDG_RUNTIME_DIR.
|
||||
@ -237,6 +278,7 @@ char* GetPath_XDG_RUNTIME_DIR()
|
||||
*/
|
||||
|
||||
path = GetEnvAlloc("XDG_RUNTIME_DIR");
|
||||
#endif
|
||||
|
||||
if (path)
|
||||
return path;
|
||||
|
Loading…
Reference in New Issue
Block a user