From e1343689774367ff1fb8f907e1e3324f0f37fec7 Mon Sep 17 00:00:00 2001 From: NPScript Date: Tue, 21 Dec 2021 09:39:56 +0100 Subject: fixes #1; no-permission preview crash fix --- luis.c | 11 +++++++++++ 1 file changed, 11 insertions(+) (limited to 'luis.c') diff --git a/luis.c b/luis.c index f14d1b8..adba1eb 100644 --- a/luis.c +++ b/luis.c @@ -9,6 +9,7 @@ #include #include #include +#include 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); } } -- cgit v1.2.3-70-g09d2