Browse Source

catch and report errors when opening files

K. Lange 9 months ago
parent
commit
35d89bfd21
2 changed files with 6 additions and 0 deletions
  1. 5 0
      bim.c
  2. 1 0
      bim.h

+ 5 - 0
bim.c

@@ -3842,6 +3842,11 @@ void open_file(char * file) {
 		}
 		f = fopen(_file, "r");
 		if (file != _file) free(_file);
+		if (!f && errno != ENOENT) {
+			render_error("%s: %s", file, strerror(errno));
+			pause_for_key();
+			return;
+		}
 		env->file_name = strdup(file);
 	}
 

+ 1 - 0
bim.h

@@ -19,6 +19,7 @@
 #include <dirent.h>
 #include <poll.h>
 #include <limits.h>
+#include <errno.h>
 #include <sys/types.h>
 #include <sys/ioctl.h>
 #include <sys/stat.h>