.# [why]
"If you use `from_path()` on a directory, then subsequent queries using that handle will fail."
Instead, use `from_path_any()` which supports opening files or directories.
ref: "Struct winapi_util::Handle" from <https://docs.rs/crate/winapi-util>
The MetadataExt functions are nightly-only right now so we need to call
the windows api ourselves to get the device number. The winapi_util
package has a nice wrapper to do this for us.
The get_device function doesn't appear to be used anywhere so I removed
it.
https://github.com/bootandy/dust/issues/46
Add -X flag used to ignore any file or directory that matches the
provided substring.
This means that -X e will ignore any file or directory with an 'e' in
it.
Removes unwrap and returns a Result instead of panicing if an invalid
path is given.
Previously if the flag: '-x' was provided with an argument of an
invalid directory the code would crash here
https://github.com/bootandy/dust/issues/50
Add optional -x flag to limit search to the current filesystem.
Add (untested) support for windows for the equivalent of inode and
device.
* Initialize ansi_term if we're on windows
* Silence build warning on non-unix targets
* Update ansi-term which has windows specific fixes (and assert_cli while I'm at it)
When one directory was a substring of another the directory would appear
as a subdirectory instead of a sibling
Fixed originally by this: 6e03dd77e6
Broken by this: db6c8a019d
Added integration test as this has bitten me before
Following the large refactor on the previous commit, this commit fixes
the reverse functionality.
Depth detection moved into the tree building instead of being calculated
when drawing the tree to screen
WIP
Replace array of (string, int) pairs with tree of nodes.
A tree of nodes more accurately represents the underlying file structure
and hence is a better fit for the problem space.
Regression: Reverse doesn't work in this commit.
I suspect more methods can be simplifed and reduced.
strip_end_slash_including_root will remove end slashes including the
root directory.
The root directory has been a long running problem because if we strip
the final slash we will run dust on no directory instead of the root.
dust sort is now more predictable as it orders first by size and second
by name.
Walkdir still gives different iteration orders on different systems so
all output is not entirely predictable
Advised to use walkdir by burntsushi as using recursion on file systems
can blow the stack.
walkdir is slower but allows the code to be cleaner and more reliable
Also experimented with ignore but locking the hashmap resulted in
similar performance to walkdir but with much uglier code.