Commit graph

12 commits

Author SHA1 Message Date
Yorhel
a830f7dfa6 Use C99 flexible array member for struct dir
This should fix https://dev.yorhel.nl/ncdu/bug/99 - with the downside
that this requires a C99 compiler.

I also replaced all occurrences of static allocation of struct dir with
use dynamic allocation, because I wasn't really sure if static
allocation of flexible structs is allowed. In the case of dirlist.c the
dynamic allocation is likely required anyway, because it does store a
few bytes in the name field.
2017-08-17 17:04:48 +02:00
Yorhel
3b55f8c137 dir_import.c: Restart fread() on EINTR
Fixes https://dev.yorhel.nl/ncdu/bug/95
2017-03-27 17:14:22 +02:00
Yorhel
e4f211db68 Year + version bump for 1.12 2016-08-24 20:59:58 +02:00
Yorhel
efece12cfe Copyright year update 2014-01-22 15:28:20 +01:00
Yorhel
fe932c7b22 Add support for browsing empty directories
Turns out that being able to open an empty directory actually has its
uses:
- If you delete the last file in a directory, you now won't be directed
  to the parent directory anymore. This allows keeping 'd' pressed
  without worrying that you'll delete stuff outside of the current dir.
  (This is the primary motivation for doing this)
- You can now scan and later refresh an empty directory, as suggested by
  #2 in http://dev.yorhel.nl/ncdu/bug/15
2014-01-22 13:30:51 +01:00
Yorhel
01f36e1beb Use /**/ comments + minor style change 2013-04-12 19:37:40 +02:00
Yorhel
267de619ba dir_import.c: Only call input_handle() once every 32 read items
Some measurements importing a gzip-compressed file (zcat .. | ncdu -f -)
containing a bit under 6 million items and a few choices of how often to
call input_handle():

Called on every item:

  real    0m13.745s
  user    0m12.576s
  sys     0m4.566s

Called on every 8 items:

  real    0m7.932s
  user    0m9.636s
  sys     0m1.623s

Called on every 16 items:

  real    0m7.559s
  user    0m9.553s
  sys     0m1.323s

Called on every 32 items:

  real    0m7.279s
  user    0m9.353s
  sys     0m1.277s

Called on every 64 items:

  real    0m7.166s
  user    0m9.389s
  sys     0m1.117s

Called on every 256 items:

  real    0m7.073s
  user    0m9.439s
  sys     0m1.027s

32 seemed like a good compromise.
2012-09-06 12:49:20 +02:00
Yorhel
37f390d241 dir_import.c: Don't throw an error when user aborted import 2012-09-06 09:47:00 +02:00
Yorhel
7d2cb84e70 Display "Loading..." instead of "Scanning..." when importing a file 2012-09-06 09:45:52 +02:00
Yorhel
38b2c8f012 dir_import.c: Various fixes
- errors in item() didn't propagate properly
- empty [] and {} values weren't allowed
- fractional numbers weren't allowed
- parsing of escaped characters didn't ensure that enough data was in
  the buffer
- E() didn't propagate errors properly in all cases

I'll do some more testing later on, but the current code seems to be
working quite well already.
2012-09-05 17:46:44 +02:00
Yorhel
e6eaec30ba dir_import.c: Put a limit on the recursion depth 2012-09-05 14:15:28 +02:00
Yorhel
10dca5503a Added -f option to import an exported directory structure
This is the first working version. There's a few TODO's left.
2012-09-05 13:52:12 +02:00