diff --git a/include/wx/stdpaths.h b/include/wx/stdpaths.h index 5528626e81..684d508659 100644 --- a/include/wx/stdpaths.h +++ b/include/wx/stdpaths.h @@ -51,6 +51,7 @@ public: enum Dir { + Dir_Cache, Dir_Documents, Dir_Desktop, Dir_Downloads, diff --git a/interface/wx/stdpaths.h b/interface/wx/stdpaths.h index 8082ff5092..9a1f3cbf9f 100644 --- a/interface/wx/stdpaths.h +++ b/interface/wx/stdpaths.h @@ -69,6 +69,16 @@ public: /// Possible values for userDir parameter of GetUserDir(). 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. diff --git a/src/msw/stdpaths.cpp b/src/msw/stdpaths.cpp index d3274701d1..29aa6b9192 100644 --- a/src/msw/stdpaths.cpp +++ b/src/msw/stdpaths.cpp @@ -223,6 +223,9 @@ wxString wxStandardPaths::GetUserDir(Dir userDir) const int csidl; switch (userDir) { + case Dir_Cache: + csidl = CSIDL_LOCAL_APPDATA; + break; case Dir_Desktop: csidl = CSIDL_DESKTOPDIRECTORY; break; diff --git a/src/osx/cocoa/stdpaths.mm b/src/osx/cocoa/stdpaths.mm index d81ef14af4..a8b8323d2a 100644 --- a/src/osx/cocoa/stdpaths.mm +++ b/src/osx/cocoa/stdpaths.mm @@ -103,6 +103,9 @@ wxString wxStandardPaths::GetUserDir(Dir userDir) const NSSearchPathDirectory dirType; switch (userDir) { + case Dir_Cache: + dirType = NSCachesDirectory; + break; case Dir_Desktop: dirType = NSDesktopDirectory; break; diff --git a/src/unix/stdpaths.cpp b/src/unix/stdpaths.cpp index 2880ff9f41..5f61f19ecb 100644 --- a/src/unix/stdpaths.cpp +++ b/src/unix/stdpaths.cpp @@ -238,6 +238,14 @@ wxString wxStandardPaths::GetUserDir(Dir userDir) const { wxLogNull logNull; 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; if (wxGetenv(wxT("XDG_CONFIG_HOME"))) configPath = wxGetenv(wxT("XDG_CONFIG_HOME")); diff --git a/tests/interactive/output.cpp b/tests/interactive/output.cpp index 7c656ae677..f72d07fa3e 100644 --- a/tests/interactive/output.cpp +++ b/tests/interactive/output.cpp @@ -404,6 +404,7 @@ void InteractiveOutputTestCase::TestStandardPaths() 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("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("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());