Commit graph

67 commits

Author SHA1 Message Date
Yorhel
97cf0fc234 Change default color scheme back to "off", fix some mdoc lints 2024-04-21 10:46:13 +02:00
Yorhel
c08340ee08 Year + version bump for 1.18.1 2023-02-12 08:44:13 +01:00
Yorhel
49e4b061a5 Backport configuration file support from 2.x 2022-11-06 13:37:33 +01:00
Yorhel
b45f8e4c06 Backport a bunch of CLI options from 2.x + sync manpage changes 2022-11-05 16:43:57 +01:00
Yorhel
9670ca66ed Backport argument parser from ncdu 2.x + add a few inverted arguments
This makes way for backporting the various new configuration options
and config file support from 2.x.
2022-11-05 12:21:30 +01:00
Yorhel
dc78e8db19 Properly mark functions without arguments as (void)
Fixes compilation with -Werror=old-style-definition
2022-11-05 10:54:37 +01:00
Yorhel
683eb26ad1 Year + version bump for 1.17 2022-04-28 11:19:27 +02:00
François Revol
e29a42a02a Some more compatibility improvements for C89 environments
This compiles now fine with gcc 2.95 on Haiku.
2022-02-08 10:02:10 +01:00
Yorhel
376aad0d35 Add dark-bg color scheme + enable colors by default if !NO_COLOR
The dark-bg scheme draws an explicit black background, so should also be
readable in terminals with a light background. That's been the main
show-stopper for enabling colors by default, as the 'dark' color scheme
is totally unreadable on light backgrounds and there's no way to detect
what background the terminal is actually using.
2021-08-16 16:07:51 +02:00
Yorhel
f982af81b0 Year + version bump for 1.16 2021-07-02 13:30:55 +02:00
Yorhel
52daeafcd8 Display setuid/setgid and sticky bits in file mode
Same way that coreutils 'ls -l' displays them.
2021-06-11 11:13:14 +02:00
Christian Göttsche
19cfe9b15c Correct misspellings 2020-05-30 19:26:00 +02:00
Christian Göttsche
84834ff370 Declare file local variables static
(cherry picked from commit ad5b7fce74)
2020-04-08 10:58:53 +02:00
Christian Göttsche
70f439d9a9 Enforce const correctness on strings
(cherry picked from commit 9801f46ece)
2020-04-08 10:53:21 +02:00
Yorhel
8d58297328 Year + version bump for 1.14.2 2020-02-10 16:02:26 +01:00
Yorhel
bb7b4196f2 Handle malloc failure by pausing any activity
This is a best-effort approach to save ncdu state when memory is low.
There's likely allocation in libraries that isn't being checked
(ncurses, printf).

Fixes #132 (it actually doesn't, that needs a 64bit static binary too,
but I'll get to that)
2019-07-23 11:03:41 +02:00
Yorhel
b6ddd491b3 Year + version bump for 1.14 2019-02-04 17:30:22 +01:00
Alex Wilson
60fdac0680 add a max modified time, or mtime, view and sorting
This adds an 'm' command to show the latest modified time of all files
in a directory. The 'M' command allows for ascending and descending
mtime sorting. These are only enabled with the -e flag and overload
the dir_ext mtime field.
2019-01-21 07:33:24 +01:00
Yorhel
14afd92ba2 Year + version bump for 1.13 2018-01-29 11:58:14 +01:00
Yorhel
3e6affa73d Display extended information in the info window
It's looking a bit cramped, but I'm lazy.
2018-01-23 14:59:46 +01:00
Yorhel
1165342dcf Don't depend on current color when creating ncurses window
Fixes a minor glitch where A_REVERSE would be set on the information
window if the last item in the dir is selected.
2018-01-23 14:20:10 +01:00
Yorhel
6c2ee0d6ab Add --color option, simple theme support, disable colors by default
I've decided not to use ls-like file name coloring for now, instead just
coloring the difference between a (regular) file and a dir.

Still looking for a good color scheme for light backgrounds.
2018-01-21 15:41:54 +01:00
Yorhel
a369a43d94 Add support for colors and sprinkle some colors around
TODO:
- Add (ls-like) colors to the actual file names
  -> Implement full $LS_COLORS handling or something simple and custom?
- Test on a white/black terminal, and provide an alternate color scheme
  if necessary.
- Make colors opt-in?
2017-07-08 16:29:31 +02:00
Yorhel
e4f211db68 Year + version bump for 1.12 2016-08-24 20:59:58 +02:00
Yorhel
79213f0d63 Support building without locale.h
Slightly modified patch from Gianluigi Tiesi.
http://dev.yorhel.nl/ncdu/bug/47
2014-04-13 08:35:46 +02:00
Yorhel
efece12cfe Copyright year update 2014-01-22 15:28:20 +01:00
Thomas Klausner
34690e4b51 util.c: Make sure to include stdarg.h
Fixes build on NetBSD.
2013-08-23 13:52:39 +02:00
Yorhel
532c32c884 Add space between file size and unit suffix
As per http://dev.yorhel.nl/ncdu/bug/31
2013-07-23 10:38:37 +02:00
Yorhel
0e9e6d511a Add --si flag for base 10 prefixes
This is a slightly modified patch contributed at

  http://dev.yorhel.nl/ncdu/bug/35
2013-07-23 10:33:24 +02:00
Chris West (Faux)
c4f5f370ac use the locale's thousand seperator, if available 2013-01-13 12:42:28 +00:00
Yorhel
28c0b58c2e Clip directory sizes to make sure they are positive
I realized that I used addparentstats() with negative values when
removing stuff, so it had to be done this way (without rewriting
everything). It's a simple solution, anyway.
2012-11-22 13:47:10 +01:00
Yorhel
ad84603bee Clip directory sizes to fit in a signed 64bit integer
This mostly avoids the issue of getting negative sizes. It's still
possible to get a negative size after refresh or deletion, I'll get to
that in a bit.
2012-11-22 13:33:32 +01:00
Yorhel
2bc1b3e479 util.c: Fix possible buffer overflow in fillsize() and formatsize()
They should now be able to cope with file sizes in the full (positive)
range of a signed integer, i.e. 0 bytes to 8 EiB minus one byte. The
size calculation of directories, however, may still overflow and cause
negative integers to be passed around. That should be fixed.
2012-11-22 12:42:57 +01:00
Yorhel
7d2cb84e70 Display "Loading..." instead of "Scanning..." when importing a file 2012-09-06 09:45:52 +02:00
Yorhel
dfbeed9daf Fixing some whitespace issues 2012-08-27 21:51:08 +02:00
Yorhel
a61c784b8c Use int instead of long for struct dir->items
2 billion files should be enough for everyone. You probably won't have
enough memory to scan such a filesystem. int is a better choice than
long, as sizeof(int) is 4 on pretty much any system where ncdu runs.
2012-08-27 18:34:45 +02:00
Yorhel
73690f8f83 Use int64_t instead of off_t
*Should* be equivalent, but having a clearly standardised width is much
better.
2012-08-27 17:20:24 +02:00
Yorhel
0fd7dec7b0 Split calc.c into separate components (dir_(mem|scan|common).c)
The architecture is explained in dir.h. The reasons for these changes is
two-fold:
- calc.c was too complex, it simply did too many things. 399ccdeb is a
  nice example of that: Should have been an easy fix, but it introduced
  a segfault (fixed in 0b49021a), and added a small memory leak.
- This architecture features a pluggable input/output system, which
  should make a file export/import feature relatively simple.

The current commit does not feature any user interface, so there's no
feedback yet when scanning a directory. I'll get to that in a bit.

I've also not tested the new scanning code very well yet, so I might
have introduced some bugs.
2012-08-26 15:29:55 +02:00
Yorhel
7fcae11d4d Copyright year bump
Damn, it's 2012 already.
2012-01-18 11:40:50 +01:00
Yorhel
5243e2daf4 Code cleanup: Use `static' where applicable.
This should also allow compilers to generate better code.
2011-10-31 15:09:49 +01:00
Yorhel
00bd015d79 Belated copyright year bump 2011-10-31 14:47:15 +01:00
Yorhel
260f138d3f util.c: Use KiB instead of kiB (bug #3399279) 2011-09-09 08:57:10 +02:00
Yorhel
6fa56c1b38 Store the name of the item in the dir struct itself
Rather than storing a pointer to another memory allocation in the
struct. This saves some memory and improves performance by significantly
decreasing the number of calls to [c|m]alloc() and free().
2010-04-28 15:32:47 +02:00
Yorhel
eed949d48d Changed directory listings to a doubly linked list
This significantly improves the performance when browsing large
directories. It is somewhat costly on the memory usage, though. :-(
2010-04-27 17:18:56 +02:00
Yorhel
fe21608e98 Correctly update directory sizes upon removing a hard link 2010-03-03 14:40:56 +01:00
Yorhel
1cc0e5a50f Only count the size of each hard link once for each directory
The displayed directory sizes are now fully correct, although in its
current state it's not all that intuitive because:

  directory size != sum(size of all files and subdirectories)

This should probably be fixed later on by splitting the sizes into a
shared and non-shared part.

Also, the sizes displayed after a recalculation or deletion are
incorrect, I'll fix this later on.
2010-02-28 16:56:45 +01:00
Yorhel
88cd199d94 Link hard linked files together with a circular linked list
The directory sizes are now incorrect as hard links will be counted
twice again (as if there wasn't any detection in the first place), but
this will get fixed by adding a shared size field.

This method of keeping track of hard links is a lot faster and allows
adding an interface which lists the found links.
2010-02-27 15:21:25 +01:00
Yorhel
101731ed13 Copyright year bump 2010-02-27 15:20:57 +01:00
Yorhel
b7d59bee5b Properly display MiB units instead of MB
Fixes bug #2831412 (debian #539553)
2009-08-03 14:26:10 +02:00
Yorhel
6de0a8ec00 Use correct hard link information after partial recalculation or deletion
Hard link detection is now done in a separate pass on the in-memory tree,
and duplicates can be 'removed' and 're-added' on the fly. When making any
changes in the tree, all hard links are re-added before the operation and
removed again afterwards.

While this guarantees that all hard link information is correct, it does
have a few drawbacks. I can currently think of two:

 1. It's not the most efficient way to do it, and may be quite slow on
    large trees. Will have to do some benchmarks later to see whether
    it is anything to be concerned about.

 2. The first encountered item is considered as 'counted' and all items
    encountered after that are considered as 'duplicate'. Because the
    order in which we traverse the tree doesn't always have to be the
    same, the items that will be considered as 'duplicate' can vary with
    each deletion or re-calculation. This might cause confusion for
    people who aren't aware of how hard links work.
2009-05-11 20:02:46 +02:00