Add support for cache directory to wxStandardPaths::GetUserDir()
This has direct equivalent under macOS and when using XDG. See #17727.
This commit is contained in:
@@ -51,6 +51,7 @@ public:
|
|||||||
|
|
||||||
enum Dir
|
enum Dir
|
||||||
{
|
{
|
||||||
|
Dir_Cache,
|
||||||
Dir_Documents,
|
Dir_Documents,
|
||||||
Dir_Desktop,
|
Dir_Desktop,
|
||||||
Dir_Downloads,
|
Dir_Downloads,
|
||||||
|
@@ -69,6 +69,16 @@ public:
|
|||||||
/// Possible values for userDir parameter of GetUserDir().
|
/// Possible values for userDir parameter of GetUserDir().
|
||||||
enum Dir
|
enum Dir
|
||||||
{
|
{
|
||||||
|
/**
|
||||||
|
Directory for caching files.
|
||||||
|
|
||||||
|
Example return values:
|
||||||
|
- Unix: @c ~/.cache
|
||||||
|
- Windows: @c "C:\Users\username\AppData\Local"
|
||||||
|
- Mac: @c ~/Library/Caches
|
||||||
|
*/
|
||||||
|
Dir_Cache,
|
||||||
|
|
||||||
/**
|
/**
|
||||||
Directory containing user documents.
|
Directory containing user documents.
|
||||||
|
|
||||||
|
@@ -223,6 +223,9 @@ wxString wxStandardPaths::GetUserDir(Dir userDir) const
|
|||||||
int csidl;
|
int csidl;
|
||||||
switch (userDir)
|
switch (userDir)
|
||||||
{
|
{
|
||||||
|
case Dir_Cache:
|
||||||
|
csidl = CSIDL_LOCAL_APPDATA;
|
||||||
|
break;
|
||||||
case Dir_Desktop:
|
case Dir_Desktop:
|
||||||
csidl = CSIDL_DESKTOPDIRECTORY;
|
csidl = CSIDL_DESKTOPDIRECTORY;
|
||||||
break;
|
break;
|
||||||
|
@@ -103,6 +103,9 @@ wxString wxStandardPaths::GetUserDir(Dir userDir) const
|
|||||||
NSSearchPathDirectory dirType;
|
NSSearchPathDirectory dirType;
|
||||||
switch (userDir)
|
switch (userDir)
|
||||||
{
|
{
|
||||||
|
case Dir_Cache:
|
||||||
|
dirType = NSCachesDirectory;
|
||||||
|
break;
|
||||||
case Dir_Desktop:
|
case Dir_Desktop:
|
||||||
dirType = NSDesktopDirectory;
|
dirType = NSDesktopDirectory;
|
||||||
break;
|
break;
|
||||||
|
@@ -238,6 +238,14 @@ wxString wxStandardPaths::GetUserDir(Dir userDir) const
|
|||||||
{
|
{
|
||||||
wxLogNull logNull;
|
wxLogNull logNull;
|
||||||
wxString homeDir = wxFileName::GetHomeDir();
|
wxString homeDir = wxFileName::GetHomeDir();
|
||||||
|
if (userDir == Dir_Cache)
|
||||||
|
{
|
||||||
|
if (wxGetenv(wxT("XDG_CACHE_HOME")))
|
||||||
|
return wxGetenv(wxT("XDG_CACHE_HOME"));
|
||||||
|
else
|
||||||
|
return homeDir + wxT("/.cache");
|
||||||
|
}
|
||||||
|
|
||||||
wxString configPath;
|
wxString configPath;
|
||||||
if (wxGetenv(wxT("XDG_CONFIG_HOME")))
|
if (wxGetenv(wxT("XDG_CONFIG_HOME")))
|
||||||
configPath = wxGetenv(wxT("XDG_CONFIG_HOME"));
|
configPath = wxGetenv(wxT("XDG_CONFIG_HOME"));
|
||||||
|
@@ -404,6 +404,7 @@ void InteractiveOutputTestCase::TestStandardPaths()
|
|||||||
wxPrintf(wxT("Data dir (user):\t%s\n"), stdp.GetUserDataDir().c_str());
|
wxPrintf(wxT("Data dir (user):\t%s\n"), stdp.GetUserDataDir().c_str());
|
||||||
wxPrintf(wxT("Data dir (user local):\t%s\n"), stdp.GetUserLocalDataDir().c_str());
|
wxPrintf(wxT("Data dir (user local):\t%s\n"), stdp.GetUserLocalDataDir().c_str());
|
||||||
wxPrintf(wxT("Documents dir:\t\t%s\n"), stdp.GetDocumentsDir().c_str());
|
wxPrintf(wxT("Documents dir:\t\t%s\n"), stdp.GetDocumentsDir().c_str());
|
||||||
|
wxPrintf(wxT("Cache dir:\t\t%s\n"), stdp.GetUserDir(wxStandardPaths::Dir_Cache).c_str());
|
||||||
wxPrintf(wxT("Desktop dir:\t\t%s\n"), stdp.GetUserDir(wxStandardPaths::Dir_Desktop).c_str());
|
wxPrintf(wxT("Desktop dir:\t\t%s\n"), stdp.GetUserDir(wxStandardPaths::Dir_Desktop).c_str());
|
||||||
wxPrintf(wxT("Downloads dir:\t\t%s\n"), stdp.GetUserDir(wxStandardPaths::Dir_Downloads).c_str());
|
wxPrintf(wxT("Downloads dir:\t\t%s\n"), stdp.GetUserDir(wxStandardPaths::Dir_Downloads).c_str());
|
||||||
wxPrintf(wxT("Music dir:\t\t%s\n"), stdp.GetUserDir(wxStandardPaths::Dir_Music).c_str());
|
wxPrintf(wxT("Music dir:\t\t%s\n"), stdp.GetUserDir(wxStandardPaths::Dir_Music).c_str());
|
||||||
|
Reference in New Issue
Block a user