Thumbnail

rani/cscroll.git

Clone URL: https://git.buni.party/rani/cscroll.git

commit 48cd1127480fdfcdb81c7bff5a20664f509189c6 Author: Raniconduh <clagv.randomgames@gmail.com> Date: Mon Oct 11 22:10:16 2021 +0000 fix handling of permission declination diff --git a/include/dir.h b/include/dir.h index 9706e72..ad077d9 100644 --- a/include/dir.h +++ b/include/dir.h @@ -363 +364 @@ extern struct dir_entry_t ** dir_entries;  extern char * cwd;    extern bool show_dot_files; +extern bool permission_denied; diff --git a/src/dir.c b/src/dir.c index 225a574..2536ead 100644 --- a/src/dir.c +++ b/src/dir.c @@ -136 +137 @@ size_t n_dir_entries = 0;  struct dir_entry_t ** dir_entries = NULL;    bool show_dot_files = false; +bool permission_denied = false;    int list_dir(char * dir_path) {   struct dirent * d_entry; @@ -208 +2111 @@ int list_dir(char * dir_path) {     n_dir_entries = 0;   - if (!dir) + if (!dir) { + permission_denied = true;   return 1; + } + permission_denied = false;     while ((d_entry = readdir(dir))) {   struct dir_entry_t * dir_entry = malloc(sizeof(struct dir_entry_t) + 12); diff --git a/src/main.c b/src/main.c index 030c2ff..e56fee8 100644 --- a/src/main.c +++ b/src/main.c @@ -537 +537 @@ int main(int argc, char ** argv) {     // print path at top   printw("\n%s", cwd); - if (!n_dir_entries) { + if (permission_denied) {   attron(COLOR_PAIR(RED));   printw("\tPermission Denied");   attroff(COLOR_PAIR(RED));