summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorYorhel <git@yorhel.nl>2018-01-23 13:40:12 +0100
committerYorhel <git@yorhel.nl>2018-01-23 13:45:16 +0100
commit47e969cdf3c010ae6984c833406fe7af379ce7ab (patch)
treec6eb9a496d46607b5947a32dce97bab0d519b038
parent77aca35fce59b222254e0dec6ba03249b8d96f78 (diff)
Add -e flag to enable extended information mode
And document the --color flag that I forgot.
-rw-r--r--doc/ncdu.pod13
-rw-r--r--src/dir_mem.c6
-rw-r--r--src/global.h2
-rw-r--r--src/main.c5
4 files changed, 23 insertions, 3 deletions
diff --git a/doc/ncdu.pod b/doc/ncdu.pod
index 6486416..3ecd28e 100644
--- a/doc/ncdu.pod
+++ b/doc/ncdu.pod
@@ -54,6 +54,19 @@ directory with many files. 10.000 files will get you an export in the order of
gzip. This scales linearly, so be prepared to handle a few tens of megabytes
when dealing with millions of files.
+=item -e
+
+Enable extended information mode. This will, in addition to the usual file
+information, also read the ownership, permissions and last modification time
+for each file. This will result in higher memory usage (by roughly ~30%) and in
+a larger output file when exporting.
+
+When using the file export/import function, this flag will need to be added
+both when exporting (to make sure the information is added to the export), and
+when importing (to read this extra information in memory). This flag has no
+effect when importing a file that has been exported without the extended
+information.
+
=back
=head2 Interface options
diff --git a/src/dir_mem.c b/src/dir_mem.c
index 03ef933..457678a 100644
--- a/src/dir_mem.c
+++ b/src/dir_mem.c
@@ -123,11 +123,11 @@ static int item(struct dir *dir, const char *name, struct dir_ext *ext) {
if(!root && orig)
name = orig->name;
- /* TODO: Don't allocate ext if -e flag is not given */
- item = malloc(dir->flags & FF_EXT ? dir_ext_memsize(name) : dir_memsize(name));
+ int extended = extended_info && (dir->flags & FF_EXT);
+ item = malloc(extended ? dir_ext_memsize(name) : dir_memsize(name));
memcpy(item, dir, offsetof(struct dir, name));
strcpy(item->name, name);
- if(dir->flags & FF_EXT)
+ if(extended)
memcpy(dir_ext_ptr(item), ext, sizeof(struct dir_ext));
item_add(item);
diff --git a/src/global.h b/src/global.h
index 5ded8cc..b998ef4 100644
--- a/src/global.h
+++ b/src/global.h
@@ -101,6 +101,8 @@ extern long update_delay;
extern int cachedir_tags;
/* flag if we should ask for confirmation when quitting */
extern int confirm_quit;
+/* flag whether we want to enable use of struct dir_ext */
+extern int extended_info;
/* handle input from keyboard and update display */
int input_handle(int);
diff --git a/src/main.c b/src/main.c
index 15d8545..9edf486 100644
--- a/src/main.c
+++ b/src/main.c
@@ -40,6 +40,7 @@ int pstate;
int read_only = 0;
long update_delay = 100;
int cachedir_tags = 0;
+int extended_info = 0;
static int min_rows = 17, min_cols = 60;
static int ncurses_init = 0;
@@ -120,6 +121,7 @@ static void argv_parse(int argc, char **argv) {
{ 'q', 0, "-q" },
{ 'v', 0, "-v" },
{ 'x', 0, "-x" },
+ { 'e', 0, "-e" },
{ 'r', 0, "-r" },
{ 'o', 1, "-o" },
{ 'f', 1, "-f" },
@@ -148,6 +150,7 @@ static void argv_parse(int argc, char **argv) {
printf(" -q Quiet mode, refresh interval 2 seconds\n");
printf(" -v Print version\n");
printf(" -x Same filesystem\n");
+ printf(" -e Enable extended information\n");
printf(" -r Read only\n");
printf(" -o FILE Export scanned directory to FILE\n");
printf(" -f FILE Import scanned directory from FILE\n");
@@ -157,12 +160,14 @@ static void argv_parse(int argc, char **argv) {
printf(" -X, --exclude-from FILE Exclude files that match any pattern in FILE\n");
printf(" --exclude-caches Exclude directories containing CACHEDIR.TAG\n");
printf(" --confirm-quit Confirm quitting ncdu\n");
+ printf(" --color SCHEME Set color scheme\n");
exit(0);
case 'q': update_delay = 2000; break;
case 'v':
printf("ncdu %s\n", PACKAGE_VERSION);
exit(0);
case 'x': dir_scan_smfs = 1; break;
+ case 'e': extended_info = 1; break;
case 'r': read_only++; break;
case 's': si = 1; break;
case 'o': export = val; break;