Commit graph

75 commits

Author SHA1 Message Date
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
b7ccf78b90 More intuitive multi-page browsing
Here is the new multi-page listing functionality I promised in
5db9c2aea1.

It may look very easy, but getting this to work right wasn't,
unfortunately.
2010-04-28 13:32:30 +02:00
Yorhel
c68a229e09 Fixed buffer overflow when some directories can't be scanned
Also changed other occurences of the same situation to use the same
checking method (>= rather than a +1) for consistency.

Fixes bug #2981704.
2010-04-28 10:08:45 +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
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
82ec5b9fa8 Misc. minor fixes 2010-02-28 10:13:12 +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
26c77cfc14 Return to previously opened directory on failed recalculation
...instead of displaying an empty and unusable browser.
2009-06-06 23:26:05 +02:00
Yorhel
e5cc7703d7 Properly free return value of opendir() on calculation interrupt
When interrupinting the calculation process by pressing 'q' while
it's looping through a directory, or when a directory could be openend
but not chdir()'ed into, closedir() wasn't called.
2009-06-06 23:22:30 +02:00
Yorhel
aef88fb773 Removed the ST_QUIT state
There shouldn't be a need for such a state when there's a central
place where the program execution keeps returning to.
2009-05-12 19:06:15 +02:00
Yorhel
9d07027553 calc.c: Removed an unused variable in calc_item() 2009-05-12 18:39:00 +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
Yorhel
8209a7efe3 Allocate correct amount of memory for the links list
I happen to make these kinds of mistakes a lot, for some strange
reason. Maybe I should just get more sleep...
2009-05-05 19:33:30 +02:00
Yorhel
fd984e754c Added hard link indicator in browser and help window 2009-05-05 19:25:52 +02:00
Yorhel
757bdff7ed Implemented hardlink detection 2009-05-05 19:13:52 +02:00
Yorhel
4ea817568f Use absolute path for matching excluded items 2009-05-02 10:45:33 +02:00
Yorhel
46de3510cd Fixed buffer overrun in calc.c 2009-05-02 10:21:29 +02:00
Yorhel
ae14721c5f Fixed segfault after aborting calculation
I really, really, wasn't think when writing commit
91b131a080
2009-04-26 15:23:09 +02:00
Yorhel
2a5c9a242f Fixed display of one-component-after-root directory
Bug introduced in ece21a668d
It's amazing how many mistakes one person can make in a few hours.
2009-04-26 13:26:20 +02:00
Yorhel
91b131a080 Fixed segault after finishing calculation
Bug introduced in 796d043c0d
Apparently I was still sleeping or something...
2009-04-26 13:15:53 +02:00
Yorhel
ece21a668d Fixed display of the root directory 2009-04-26 13:10:00 +02:00
Yorhel
9cc79b0fab Properly call calc_leavepath() on error 2009-04-26 12:58:22 +02:00
Yorhel
796d043c0d Fixed bug with opening the root directory 2009-04-26 12:55:27 +02:00
Yorhel
290c7a7d70 Renamed ncdu.h to global.h and #included all other header files into that
So we're actually back to having one header file for everything,
except it's now maintainable.
2009-04-26 11:08:40 +02:00
Yorhel
ba243df042 Centralized screen update delay into input_handle() 2009-04-26 09:49:51 +02:00
Yorhel
8ddec92724 Huge performance improvement with the calculation 2009-04-26 09:35:16 +02:00
Yorhel
c079e0d23a Fixed another memory allocation issue 2009-04-25 16:30:59 +02:00
Yorhel
3dc21365f5 Fixed another PATH_MAX reliance in calc.c
Make sure not to pass the absolute root directory to lstat() and
chdir(), as these functions can't handle long path names.
2009-04-25 14:31:54 +02:00
Yorhel
c432928bd2 Fixed subdirectory name after refresh and a tiny memory leak 2009-04-25 14:29:20 +02:00
Yorhel
18211ebe2e Properly chdir() before lstat() 2009-04-25 11:49:20 +02:00
Yorhel
4bb7d6b7c2 Removed reliance on PATH_MAX on most places
ncdu already does seem to handle longer paths now, though there are
still a few places where the code still relies on PATH_MAX. Will fix
those later.
2009-04-23 21:15:11 +02:00
Yorhel
7698bfd980 Split path handling into path.c and replaced rpath() with a better implementation
This is the first step into replacing all code that relies on PATH_MAX,
more changes will follow.
2009-04-23 19:44:37 +02:00
Yorhel
d75cc8fb72 Replace 'suseconds_t' with 'long'
suseconds_t isn't always defined on some systems, but all possible
values are guaranteed to fit into a long, so use that.
2009-04-19 14:29:49 +02:00
Yorhel
76a2530579 Fixed bug in calculation window title 2009-04-19 09:45:27 +02:00
Yorhel
33cd126197 Draw browser on background while calculating 2009-04-18 15:35:37 +02:00
Yorhel
e079026ac8 Kept internal variables internal in browser.c and added browse_init()
Looks much better this way!
2009-04-18 15:23:33 +02:00
Yorhel
3ad39f3741 Don't touch the original tree while recalculating
This change makes it possible to still show the browser with correct
(previous) data while calculating.
2009-04-18 15:07:23 +02:00
Yorhel
4a751f0564 Removed stcalc and used several global variables instead
Considering it's now all internal in calc.c, anyway.
2009-04-18 14:36:24 +02:00
Yorhel
372f69853c Initialize calc_delay and calc_smfs in calc.c rather than main.c 2009-04-18 14:16:48 +02:00
Yorhel
b24c3dee40 Got rid of SF_SI
It was a totally useless feature, anyway.
2009-04-18 14:05:45 +02:00
Yorhel
2b209ba9b2 Moved SF_SMFS in ncdu.h to char calc_smfs in calc.h
Another code cleanup, many more to come...
2009-04-18 14:04:53 +02:00
Yorhel
2a25bfdc7a Moved and renamed sdelay in ncdu.h to calc_delay in calc.h
Because that's where it's supposed to be.
(geez, the current code is still a mess)
2009-04-18 13:51:45 +02:00
Yorhel
05756ad567 Remove some calc.c specific defines from ncdu.h
And updated TODO a bit
2009-04-18 13:45:32 +02:00
Yorhel
6d5ae5eb76 Fixed minor size + item count inconsistency on recalculating a dir
Namely, the 'parent' dir item itself that is recalculated isn't
reconsidered in its parents.
2009-04-16 19:05:11 +02:00
Yorhel
d297af2ce8 Fixed major bug with counting all sizes twice
I have absolutely no idea when I introduced this bug, will check
the history later.
2009-04-16 19:00:13 +02:00
Yorhel
34ba5348c8 Made stcalc static within calc.c and abstracted access to it with calc_init()
This actually makes the struct itself obsolete, as all information is now only
useful within calc.c itself and other files don't have to do anything with it.
2009-04-16 18:26:39 +02:00
Yorhel
5790b817f9 Re-added recalculating (sub)directories 2009-04-13 19:32:40 +02:00
Yorhel
b8877be907 Fixed display bug while calculating 2009-04-13 18:38:07 +02:00
Yorhel
7a0730f5d2 (Partly) rewrote browser.c to the new system
Not fully finished yet with this one, though.
2009-04-13 17:25:46 +02:00