From 4fea54637bb8eef89fb08cff21788bf3565a54ee Mon Sep 17 00:00:00 2001 From: C. McEnroe Date: Tue, 12 May 2020 12:44:38 -0400 Subject: 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. --- xdg.c | 20 ++++---------------- 1 file changed, 4 insertions(+), 16 deletions(-) (limited to 'xdg.c') diff --git a/xdg.c b/xdg.c index c70873a..ee51ed5 100644 --- a/xdg.c +++ b/xdg.c @@ -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++; } -- cgit 1.4.1-2-gfad0