Support XDG Base directory specification for Linux - #264
Conversation
|
I'm pretty sure this will still run into the issues I fixed here: arch1t3cht@b5a071b Also worth noting that this will break regardless due to this line in Dependency Control (https://github.com/TypesettingTools/DependencyControl/blob/9b8d615f18e295f4777ea606a7173465bdaf140d/modules/DependencyControl/Record.moon#L44). It needs to be changed in there as well |
You're right, I will fix it. |
| throw agi::EnvironmentError("Could not get home directory. Make sure HOME is set."); | ||
| } | ||
|
|
||
| std::string xdg_dir(std::string_view token, agi::fs::path const& fallback) { |
There was a problem hiding this comment.
token is not the right name for the parameter... (env_name would be better)
| SetToken("?state", old_root); | ||
| } else { | ||
| SetToken("?user", xdg_config/"aegisub"); | ||
| SetToken("?local", xdg_cache/"aegisub"); |
There was a problem hiding this comment.
Calling a cache dir ?local is somewhat misleading, but I guess we have to keep it for compatibility. ?cache would be a better name though.
There was a problem hiding this comment.
Calling a cache dir
?localis somewhat misleading, but I guess we have to keep it for compatibility.?cachewould be a better name though.
This is because the data originally stored in ?local is suppose to be store in the xdg cache dir. I think it would be better to keep this currently for compatibility.
|
|
||
| std::string xdg_dir(std::string_view token, agi::fs::path const& fallback) { | ||
| const char *env = getenv(token.data()); | ||
| if (env) return env; |
There was a problem hiding this comment.
The environment variable must be ignored if it is empty or doesn't contain an absolute path
There was a problem hiding this comment.
The environment variable must be ignored if it is empty or doesn't contain an absolute path
agi::Path::SetToken will treat the path like this:
void Path::SetToken(std::string_view token_name, fs::path const& token_value) {
int idx = checked_find_token(token_name);
if (token_value.empty())
paths[idx] = token_value;
else if (!token_value.is_absolute())
paths[idx].clear();
else {
paths[idx] = token_value;
paths[idx].make_preferred();
if (fs::FileExists(paths[idx]))
paths[idx] = paths[idx].parent_path();
}
}I think I don't need to do anymore.
|
This PR causes a crash on startup when the XDG dirs don't exist. This part of the spec is relevent:
|
Support added in TypesettingTools/DependencyControl#36. |
Ref: 1. https://specifications.freedesktop.org/basedir-spec/latest 2. aria2/aria2@8bc1d37 Fix compile issue caused by token to path mapping Co-authored-by: witchymary <63314339+witchymary@users.noreply.github.com>
fa912a0 to
b22bd38
Compare
|
Make some refactors and rebase on the latest commit on |
This PR will fix Issue Aegisub#226. Adapted from aria2/aria2@8bc1d37.
The basic idea just is:
The original PR is here: wangqr#132