linux - 我可以假设 .cache 目录存在吗?

标签 linux caching posix

我想在 $HOME/.cache 中缓存一些文件,但我不知道在什么操作系统下我可以假设它已经存在。如果没有,我可以尝试自己创建它吗,或者这是一个错误?什么实体创造它? .cache 的位置是标准化的吗?按照什么标准?

最佳答案

(Linux) 文件系统层次结构

Linux file system hierarchy (man hier)并不意味着任何 $HOME/.cache 目录。从那个手册页,我添加了突出显示:

/home

On machines with home directories for users, these are usually beneath this directory, directly or not. The structure of this directory depends on local administration decisions.

freedesktop.org 规范

.config.cache 目录是specified by freedesktop.org as reasonable defaults到环境变量 $XDG_CONFIG_HOME$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.

要遵循他们的规范,您可能需要先阅读 $XDG_CACHE_HOME,如果未设置,请使用 $HOME/.cache 并在必要时创建它。您会经常遇到这些未设置的变量——事实上,它在我的任何一台机器上都没有设置。

关于linux - 我可以假设 .cache 目录存在吗?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/22742923/

相关文章:

java - 调色板颜色缓存的单例实例

objective-c - 在iPhone/iPad上缓存数据的正确方法

c# - ServiceStack.Redis 搜索缓存

linux - 编译linux驱动的步骤

c - fork+exec 没有 atfork 处理程序

bash - 排序实用程序的字母顺序是什么?

c++ - Visual Studio 2013中的POSIX header (来自MinGW项目)

代码块不在 linux lite 中编译空 c 文件

linux - 使用 Bash 检查另一个目录中是否存在相同的文件

linux - 如何摆脱 'GLIBCXX_3.4.9 not found error' ?