about summary refs log tree commit diff
diff options
context:
space:
mode:
authorJune McEnroe <june@causal.agency>2020-05-12 12:44:38 -0400
committerJune McEnroe <june@causal.agency>2020-05-12 12:44:38 -0400
commit4fea54637bb8eef89fb08cff21788bf3565a54ee (patch)
tree070a6e3bef3195714b04e31da084b06f4687297e
parentMark global variables in chat.h as extern (diff)
downloadcatgirl-4fea54637bb8eef89fb08cff21788bf3565a54ee.tar.gz
catgirl-4fea54637bb8eef89fb08cff21788bf3565a54ee.zip
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.
Diffstat (limited to '')
-rw-r--r--xdg.c20
1 files changed, 4 insertions, 16 deletions
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++;
 	}