aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNPScript <nathan@reinerweb.ch>2021-12-21 09:39:56 +0100
committerNPScript <nathan@reinerweb.ch>2021-12-21 09:39:56 +0100
commite1343689774367ff1fb8f907e1e3324f0f37fec7 (patch)
tree6174f45918267af02718175cc8bd0ad63d88a8d1
parente7f5449080dbf4e60bca9a2b2e3ce670d289d496 (diff)
fixes #1; no-permission preview crash fix
-rw-r--r--luis.c11
1 files changed, 11 insertions, 0 deletions
diff --git a/luis.c b/luis.c
index f14d1b8..adba1eb 100644
--- a/luis.c
+++ b/luis.c
@@ -9,6 +9,7 @@
#include <magic.h>
#include <limits.h>
#include <unistd.h>
+#include <errno.h>
const char DTC[] = {
[DT_BLK] = 'b',
@@ -230,6 +231,16 @@ void print_preview(Window * win) {
SET_COLOR(100, 100, 100);
printfxy_to_window(win, 0, 5, "Content");
RESET_VIDEO();
+
+ DIR * dir = opendir(filepath);
+
+ if (dir == NULL) {
+ SET_COLOR(180, 60, 60);
+ printfxy_to_window(win, 0, 7, strerror(errno));
+ RESET_VIDEO();
+ return;
+ }
+
write_dir_content_to_win(win, filepath, -1, 7);
}
}