Backport --(enable|disable)-(shell|delete|refresh) from 2.x
Only remaining options missing from this C implementation are --graph-style (sounds doable, but pretty low priority) and --shared-column (unlikely to happen).
Этот коммит содержится в:
родитель
49e4b061a5
Коммит
6dd159d489
38
doc/ncdu.pod
38
doc/ncdu.pod
@ -167,22 +167,29 @@ decreased to once every 2 seconds with C<-q> or C<--slow-ui-updates>. This
|
|||||||
feature can be used to save bandwidth over remote connections. This option has
|
feature can be used to save bandwidth over remote connections. This option has
|
||||||
no effect when C<-0> is used.
|
no effect when C<-0> is used.
|
||||||
|
|
||||||
|
=item B<--enable-shell>, B<--disable-shell>
|
||||||
|
|
||||||
|
Enable or disable shell spawning from the browser. This feature is enabled by
|
||||||
|
default when scanning a live directory and disabled when importing from file.
|
||||||
|
|
||||||
|
=item B<--enable-delete>, B<--disable-delete>
|
||||||
|
|
||||||
|
Enable or disable the built-in file deletion feature. This feature is enabled
|
||||||
|
by default when scanning a live directory and disabled when importing from
|
||||||
|
file. Explicitly disabling the deletion feature can work as a safeguard to
|
||||||
|
prevent accidental data loss.
|
||||||
|
|
||||||
|
=item B<--enable-refresh>, B<--disable-refresh>
|
||||||
|
|
||||||
|
Enable or disable directory refreshing from the browser. This feature is
|
||||||
|
enabled by default when scanning a live directory and disabled when importing
|
||||||
|
from file.
|
||||||
|
|
||||||
=item B<-r>
|
=item B<-r>
|
||||||
|
|
||||||
Read-only mode. This will disable the built-in file deletion feature. This
|
Read-only mode. When given once, this is an alias for C<--disable-delete>, when
|
||||||
option has no effect when C<-o> is used, because there will not be a browser
|
given twice it will also add C<--disable-shell>, thus ensuring that there is no
|
||||||
interface in that case. It has no effect when C<-f> is used, either, because
|
way to modify the file system from within ncdu.
|
||||||
the deletion feature is disabled in that case anyway.
|
|
||||||
|
|
||||||
WARNING: This option will only prevent deletion through the file browser. It is
|
|
||||||
still possible to spawn a shell from ncdu and delete or modify files from
|
|
||||||
there. To disable that feature as well, pass the C<-r> option twice (see
|
|
||||||
C<-rr>).
|
|
||||||
|
|
||||||
=item B<-rr>
|
|
||||||
|
|
||||||
In addition to C<-r>, this will also disable the shell spawning feature of the
|
|
||||||
file browser.
|
|
||||||
|
|
||||||
=item B<--si>, B<--no-si>
|
=item B<--si>, B<--no-si>
|
||||||
|
|
||||||
@ -272,6 +279,9 @@ starting with C<#> are ignored. Example configuration file:
|
|||||||
# Always enable extended mode
|
# Always enable extended mode
|
||||||
-e
|
-e
|
||||||
|
|
||||||
|
# Disable file deletion
|
||||||
|
--disable-delete
|
||||||
|
|
||||||
# Exclude .git directories
|
# Exclude .git directories
|
||||||
--exclude .git
|
--exclude .git
|
||||||
|
|
||||||
|
@ -272,7 +272,7 @@ void browse_draw(void) {
|
|||||||
addstrc(UIC_HD, " for help");
|
addstrc(UIC_HD, " for help");
|
||||||
if(dir_import_active)
|
if(dir_import_active)
|
||||||
mvaddstr(0, wincols-10, "[imported]");
|
mvaddstr(0, wincols-10, "[imported]");
|
||||||
else if(read_only)
|
else if(!can_delete)
|
||||||
mvaddstr(0, wincols-11, "[read-only]");
|
mvaddstr(0, wincols-11, "[read-only]");
|
||||||
|
|
||||||
/* second line - the path */
|
/* second line - the path */
|
||||||
@ -323,7 +323,7 @@ void browse_draw(void) {
|
|||||||
if(message) {
|
if(message) {
|
||||||
nccreate(6, 60, "Message");
|
nccreate(6, 60, "Message");
|
||||||
ncaddstr(2, 2, message);
|
ncaddstr(2, 2, message);
|
||||||
ncaddstr(4, 34, "Press any key to continue");
|
ncaddstr(4, 33, "Press any key to continue");
|
||||||
}
|
}
|
||||||
|
|
||||||
/* draw information window */
|
/* draw information window */
|
||||||
@ -488,8 +488,8 @@ int browse_key(int ch) {
|
|||||||
|
|
||||||
/* and other stuff */
|
/* and other stuff */
|
||||||
case 'r':
|
case 'r':
|
||||||
if(dir_import_active) {
|
if(!can_refresh) {
|
||||||
message = "Directory imported from file, won't refresh.";
|
message = "Directory refresh feature disabled.";
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
if(dirlist_par) {
|
if(dirlist_par) {
|
||||||
@ -527,14 +527,12 @@ int browse_key(int ch) {
|
|||||||
info_show = 0;
|
info_show = 0;
|
||||||
break;
|
break;
|
||||||
case 'd':
|
case 'd':
|
||||||
if(read_only >= 1 || dir_import_active) {
|
|
||||||
message = read_only >= 1
|
|
||||||
? "File deletion disabled in read-only mode."
|
|
||||||
: "File deletion not available for imported directories.";
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
if(sel == NULL || sel == dirlist_parent)
|
if(sel == NULL || sel == dirlist_parent)
|
||||||
break;
|
break;
|
||||||
|
if(!can_delete) {
|
||||||
|
message = "Deletion feature disabled.";
|
||||||
|
break;
|
||||||
|
}
|
||||||
info_show = 0;
|
info_show = 0;
|
||||||
if((t = dirlist_get(1)) == sel)
|
if((t = dirlist_get(1)) == sel)
|
||||||
if((t = dirlist_get(-1)) == sel || t == dirlist_parent)
|
if((t = dirlist_get(-1)) == sel || t == dirlist_parent)
|
||||||
@ -542,10 +540,8 @@ int browse_key(int ch) {
|
|||||||
delete_init(sel, t);
|
delete_init(sel, t);
|
||||||
break;
|
break;
|
||||||
case 'b':
|
case 'b':
|
||||||
if(read_only >= 2 || dir_import_active) {
|
if(!can_shell) {
|
||||||
message = read_only >= 2
|
message = "Shell feature disabled.";
|
||||||
? "Shell feature disabled in read-only mode."
|
|
||||||
: "Shell feature not available for imported directories.";
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
shell_init();
|
shell_init();
|
||||||
|
@ -95,8 +95,10 @@ struct dir_ext {
|
|||||||
|
|
||||||
/* program state */
|
/* program state */
|
||||||
extern int pstate;
|
extern int pstate;
|
||||||
/* read-only flag, 1+ = disable deletion, 2+ = also disable shell */
|
/* enabled features */
|
||||||
extern int read_only;
|
extern int can_delete;
|
||||||
|
extern int can_shell;
|
||||||
|
extern int can_refresh;
|
||||||
/* minimum screen update interval when calculating, in ms */
|
/* minimum screen update interval when calculating, in ms */
|
||||||
extern long update_delay;
|
extern long update_delay;
|
||||||
/* filter directories with CACHEDIR.TAG */
|
/* filter directories with CACHEDIR.TAG */
|
||||||
|
17
src/main.c
17
src/main.c
@ -35,7 +35,9 @@
|
|||||||
|
|
||||||
|
|
||||||
int pstate;
|
int pstate;
|
||||||
int read_only = 0;
|
int can_delete = -1;
|
||||||
|
int can_shell = -1;
|
||||||
|
int can_refresh = -1;
|
||||||
long update_delay = 100;
|
long update_delay = 100;
|
||||||
int cachedir_tags = 0;
|
int cachedir_tags = 0;
|
||||||
int extended_info = 0;
|
int extended_info = 0;
|
||||||
@ -197,7 +199,14 @@ static int arg_option(void) {
|
|||||||
else if(OPT("--cross-file-system")) dir_scan_smfs = 0;
|
else if(OPT("--cross-file-system")) dir_scan_smfs = 0;
|
||||||
else if(OPT("-e") || OPT("--extended")) extended_info = 1;
|
else if(OPT("-e") || OPT("--extended")) extended_info = 1;
|
||||||
else if(OPT("--no-extended")) extended_info = 0;
|
else if(OPT("--no-extended")) extended_info = 0;
|
||||||
else if(OPT("-r")) read_only++;
|
else if(OPT("-r") && !can_delete) can_shell = 0;
|
||||||
|
else if(OPT("-r")) can_delete = 0;
|
||||||
|
else if(OPT("--enable-shell")) can_shell = 1;
|
||||||
|
else if(OPT("--disable-shell")) can_shell = 0;
|
||||||
|
else if(OPT("--enable-delete")) can_delete = 1;
|
||||||
|
else if(OPT("--disable-delete")) can_delete = 0;
|
||||||
|
else if(OPT("--enable-refresh")) can_refresh = 1;
|
||||||
|
else if(OPT("--disable-refresh")) can_refresh = 0;
|
||||||
else if(OPT("--show-hidden")) dirlist_hidden = 0;
|
else if(OPT("--show-hidden")) dirlist_hidden = 0;
|
||||||
else if(OPT("--hide-hidden")) dirlist_hidden = 1;
|
else if(OPT("--hide-hidden")) dirlist_hidden = 1;
|
||||||
else if(OPT("--show-itemcount")) show_items = 1;
|
else if(OPT("--show-itemcount")) show_items = 1;
|
||||||
@ -406,6 +415,10 @@ static void argv_parse(int argc, char **argv) {
|
|||||||
* feedback when exporting to stdout. */
|
* feedback when exporting to stdout. */
|
||||||
if(dir_ui == -1)
|
if(dir_ui == -1)
|
||||||
dir_ui = export && strcmp(export, "-") == 0 ? 0 : export ? 1 : 2;
|
dir_ui = export && strcmp(export, "-") == 0 ? 0 : export ? 1 : 2;
|
||||||
|
|
||||||
|
if(can_delete == -1) can_delete = import ? 0 : 1;
|
||||||
|
if(can_shell == -1) can_shell = import ? 0 : 1;
|
||||||
|
if(can_refresh == -1) can_refresh = import ? 0 : 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
Загрузка…
Ссылка в новой задаче
Block a user