From 7a9072e20ad89d8fd88a5b1c19e1dc3952cea755 Mon Sep 17 00:00:00 2001 From: Marcel Rodrigues Date: Thu, 15 Dec 2016 20:37:14 -0200 Subject: [PATCH] Add 'E' command to toggle execute permission of file. --- README.md | 1 + config.h | 1 + rover.1 | 3 +++ rover.c | 12 ++++++++++++ 4 files changed, 17 insertions(+) diff --git a/README.md b/README.md index f6f9a9b..96a9b99 100644 --- a/README.md +++ b/README.md @@ -46,6 +46,7 @@ Quick Start f/d/s - toggle file/directory/hidden listing n/N - create new file/directory R - rename selected file or directory + E - toggle execute permission of the selected file D - delete selected file or (empty) directory m - toggle mark on the selected entry M - toggle mark on all visible entries diff --git a/config.h b/config.h index c2b644c..ef7ad98 100644 --- a/config.h +++ b/config.h @@ -26,6 +26,7 @@ #define RVK_NEW_FILE "n" #define RVK_NEW_DIR "N" #define RVK_RENAME "R" +#define RVK_TG_EXEC "E" #define RVK_DELETE "D" #define RVK_TG_MARK "m" #define RVK_INVMARK "M" diff --git a/rover.1 b/rover.1 index 321a61c..6cb7e1f 100644 --- a/rover.1 +++ b/rover.1 @@ -126,6 +126,9 @@ Create new file/directory. .B R Rename selected file or directory. .TP +.B E +Toggle execute permission of the selected file. +.TP .B D Delete selected file or (empty) directory. .TP diff --git a/rover.c b/rover.c index 2665a98..640d0d5 100644 --- a/rover.c +++ b/rover.c @@ -1356,6 +1356,18 @@ main(int argc, char *argv[]) } else message(RED, "\"%s\" already exists.", INPUT); } + } else if (!strcmp(key, RVK_TG_EXEC)) { + if (!rover.nfiles || S_ISDIR(EMODE(ESEL))) continue; + if (S_IXUSR & EMODE(ESEL)) + EMODE(ESEL) &= ~(S_IXUSR | S_IXGRP | S_IXOTH); + else + EMODE(ESEL) |= S_IXUSR | S_IXGRP | S_IXOTH ; + if (chmod(ENAME(ESEL), EMODE(ESEL))) { + message(RED, "Failed to change mode of \"%s\".", ENAME(ESEL)); + } else { + message(GREEN, "Changed mode of \"%s\".", ENAME(ESEL)); + update_view(); + } } else if (!strcmp(key, RVK_DELETE)) { if (rover.nfiles) { message(YELLOW, "Delete \"%s\"? (Y/n)", ENAME(ESEL)); -- 2.11.4.GIT