Comments (3)
I don't really understand your point here. Each path
in the paths
slice is checked in turn for existence. And the paths
are sorted by their priority (home directory paths first).
If we take the xdg.DataFile
function as an example. Let's say these are the searched paths:
[~/.local/share, /usr/local/share, /usr/share]
(composed by XDG_DATA_HOME
+ XDG_DATA_DIRS
)
and I want to create myapp/app.data
.
In that case, createPath
would first look if ~/.local/share/myapp
exists. If it doesn't, it would create it and stop.
If the directories cannot be created, the next path
in the paths
slice is attempted and so on until it succeeds or there are no more paths.
The files should always be written in the order of the paths
, even though not all of them exist. If the first one in the slice does not exist, it should be created. If that succeeds, then that's the path at which the data file should be written.
EDIT: in your example, /usr/local/share
would not be created because a home directory
path of the root user would be attempted first. Only if that fails, the next path is attempted. And as I mentioned, priority matters. Paths should be created in the order of the priority they are defined either in the XDG variable in question or in the order of the defaults if that variable is not set.
from xdg.
@KalleDK Can this issue be closed?
To summarize:
createPath
is used by xdg.DataFile
, xdg.ConfigFile
, xdg.CacheFile
, xdg.RuntimeFile
and xdg.StateFile
.
For all of them, paths are created relative to XDG_DATA_HOME
, XDG_CONFIG_HOME
, XDG_CACHE_HOME
, XDG_RUNTIME_DIR
and XDG_STATE_HOME
. Defaults are used for variables which are not defined or are empty.
For xdg.DataFile
and xdg.ConfigFile
, in addition to XDG_DATA_HOME
and XDG_CONFIG_HOME
, XDG_DATA_DIRS
and XDG_CONFIG_DIRS
are used as fallbacks. They are used only if paths cannot be created relative to XDG_DATA_HOME
and XDG_CONFIG_HOME
. So that should never happen, as users should always be able to create directories inside their home directory. However, if that happens for any reason, path creation is attempted relative to the paths defined by XDG_DATA_DIRS
/XDG_CONFIG_DIRS
, in the order they are defined in the variable by the user/system (or in the order of the defaults if it is not defined). Realistically, fallbacks are never used.
from xdg.
Closing this issue. Please re-open if I missed anything.
from xdg.
Related Issues (13)
- Support more XDG directories HOT 4
- Plan 9 support HOT 3
- On windows please use KnownfolderPath HOT 4
- Parse ~/.config/user-dirs.dirs file HOT 6
- Custom file system support? HOT 4
- `Create` may set up wrong permissions for some directories in the path HOT 8
- Dupplicate `homeDir`'s implementation HOT 2
- macOS: do not use ~/Library/Preferences HOT 3
- DataDirs no longer used HOT 7
- Provide CacheDir function HOT 2
- Remove might be a bit to harsh HOT 3
- Should not change permissions without consent HOT 2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from xdg.