Do not stop when files in XDG dirs are inaccessible

> When attempting to read a file, if for any reason a file in a certain
> directory is unaccessible, e.g. because the directory is non-existant,
> the file is non-existant or the user is not authorized to open the file,
> then the processing of the file in that directory should be skipped. If
> due to this a required file could not be found at all, the application
> may chose to present an error message to the user.
weechat-hashes
C. McEnroe 2020-05-12 12:44:38 -04:00
parent bde0f47a70
commit 4fea54637b
1 changed files with 4 additions and 16 deletions

20
xdg.c
View File

@ -42,10 +42,7 @@ FILE *configOpen(const char *path, const char *mode) {
}
FILE *file = fopen(buf, mode);
if (file) return file;
if (errno != ENOENT) {
warn("%s", buf);
return NULL;
}
if (errno != ENOENT) warn("%s", buf);
if (!configDirs) configDirs = "/etc/xdg";
while (*configDirs) {
@ -56,10 +53,7 @@ FILE *configOpen(const char *path, const char *mode) {
);
file = fopen(buf, mode);
if (file) return file;
if (errno != ENOENT) {
warn("%s", buf);
return NULL;
}
if (errno != ENOENT) warn("%s", buf);
configDirs += len;
if (*configDirs) configDirs++;
}
@ -92,10 +86,7 @@ FILE *dataOpen(const char *path, const char *mode) {
}
FILE *file = fopen(homePath, mode);
if (file) return file;
if (errno != ENOENT) {
warn("%s", homePath);
return NULL;
}
if (errno != ENOENT) warn("%s", homePath);
char buf[PATH_MAX];
if (!dataDirs) dataDirs = "/usr/local/share:/usr/share";
@ -107,10 +98,7 @@ FILE *dataOpen(const char *path, const char *mode) {
);
file = fopen(buf, mode);
if (file) return file;
if (errno != ENOENT) {
warn("%s", buf);
return NULL;
}
if (errno != ENOENT) warn("%s", buf);
dataDirs += len;
if (*dataDirs) dataDirs++;
}