diff options
Diffstat (limited to 'gdb/common')
-rw-r--r-- | gdb/common/pathstuff.c | 10 | ||||
-rw-r--r-- | gdb/common/pathstuff.h | 10 |
2 files changed, 16 insertions, 4 deletions
diff --git a/gdb/common/pathstuff.c b/gdb/common/pathstuff.c index 2d9dcb2..3dd58e3 100644 --- a/gdb/common/pathstuff.c +++ b/gdb/common/pathstuff.c @@ -164,6 +164,13 @@ contains_dir_separator (const char *path) std::string get_standard_cache_dir () { +#ifdef __APPLE__ +#define HOME_CACHE_DIR "Library/Caches" +#else +#define HOME_CACHE_DIR ".cache" +#endif + +#ifndef __APPLE__ char *xdg_cache_home = getenv ("XDG_CACHE_HOME"); if (xdg_cache_home != NULL) { @@ -171,13 +178,14 @@ get_standard_cache_dir () gdb::unique_xmalloc_ptr<char> abs (gdb_abspath (xdg_cache_home)); return string_printf ("%s/gdb", abs.get ()); } +#endif char *home = getenv ("HOME"); if (home != NULL) { /* Make sure the path is absolute and tilde-expanded. */ gdb::unique_xmalloc_ptr<char> abs (gdb_abspath (home)); - return string_printf ("%s/.cache/gdb", abs.get ()); + return string_printf ("%s/" HOME_CACHE_DIR "/gdb", abs.get ()); } return {}; diff --git a/gdb/common/pathstuff.h b/gdb/common/pathstuff.h index d1aa6b3..a43b963 100644 --- a/gdb/common/pathstuff.h +++ b/gdb/common/pathstuff.h @@ -53,10 +53,14 @@ extern bool contains_dir_separator (const char *path); /* Get the usual user cache directory for the current platform. On Linux, it follows the XDG Base Directory specification: use - $XDG_CACHE_HOME/gdb if the XDG_CACHE_HOME environment variable is defined, - otherwise $HOME/.cache. The return value is absolute and tilde-expanded. + $XDG_CACHE_HOME/gdb if the XDG_CACHE_HOME environment variable is + defined, otherwise $HOME/.cache. - Return an empty string if neither XDG_CACHE_HOME or HOME are defined. */ + On macOS, it follows the local convention and uses + ~/Library/Caches/gdb. + + The return value is absolute and tilde-expanded. Return an empty + string if neither XDG_CACHE_HOME (on Linux) or HOME are defined. */ extern std::string get_standard_cache_dir (); |