122 Commits

Author SHA1 Message Date
Andrew Gallant
2863f281e7
windows: more carefuly is_dir checking
This fixes a bug where a symlink was followed even if the user did not
request it. Namely, on Windows, a symlink can be interpreted as both a
symlink and a directory, given our new is_dir checking.
2018-02-01 22:50:55 -05:00
Andrew Gallant
dc4c1ccea1
windows: use entry file type
Using fs::metadata will always read through a link, and we want to
preserve the type of the original entry.
2018-02-01 22:49:59 -05:00
Andrew Gallant
01ee572ab4
gitignore: add tmp dir 2018-02-01 22:49:07 -05:00
Andrew Gallant
a838cd6c68
2.1.2 2.1.2 2018-02-01 21:08:20 -05:00
Andrew Gallant
0f4441f9bc
windows: fix OneDrive traversals
This commit fixes a bug on Windows where walkdir refused to traverse
directories that resided on OneDrive via its "file on demand" strategy.
The specific bug is that Rust's standard library treats a reparse point
(which is what OneDrive uses) as distinct from a file or directory, which
wreaks havoc on any code that uses FileType::{is_file, is_dir}. We fix
this by checking the directory status of a file by looking only at whether
its directory bit is set.

This bug was originally reported in ripgrep:
https://github.com/BurntSushi/ripgrep/issues/705

It has also been filed upstream:
https://github.com/rust-lang/rust/issues/46484

And has a pending fix:
https://github.com/rust-lang/rust/pull/47956
2018-02-01 21:08:16 -05:00
Andrew Gallant
42a5b959f1
2.1.1 2.1.1 2018-02-01 17:03:47 -05:00
Andrew Gallant
e2b898329f
traversal: more robust error handling
This fixes a bug in walkdir that happened on Windows when following
symlinks. It was triggered when opening a handle to the symlink failed.
In particular, this resulted in the two stacks in the walkdir iterator
getting out of sync. At some point, this tripped a panic when popping
from one stack would be fine but popping from the other failed because
it was empty.

We fix this by only pushing to both stacks if and only if both pushes
would succeed.

This bug was found via ripgrep. See:
https://github.com/BurntSushi/ripgrep/issues/633#issuecomment-339076246
2018-02-01 17:01:08 -05:00
Andrew Gallant
34857644e6
2.1.0 2.1.0 2018-01-30 20:25:20 -05:00
Garrett Berg
b03670ee30 errors: keep context when converting to io::Error
This commit tweaks the `From<walkdir::Error> for io::Error`
implementation to always retain the current context when
constructing the `io::Error`. This differs from the previous
implementation in that the original raw I/O error is no longer
returned.

To compensate, a new method, `into_io_error`, has been
added which returns the original I/O error, if one exists.

We do not consider this a breaking change because the
documentation for the `From` impl always stated that it
existed for ergonomic reasons. Arguably, the implementation
in this commit is a more faithful reflection of that
documentation.

This commit also clears up the public documentation
surrounding the aforementioned methods.
2018-01-30 20:24:28 -05:00
Jason Grlicky
9775f531be docs: fix a couple broken links 2018-01-17 08:58:56 -05:00
Igor Gnatenko
791d6034cc deps: bump quickcheck to 0.6 and rand to 0.4 2017-12-31 19:44:50 -05:00
Andrew Gallant
cf6d422edb
2.0.1 2.0.1 2017-10-21 18:55:02 -04:00
Andrew Gallant
286bb1f3aa
doc: formatting
Doc strings on public items should always start with a short one
sentence description. This is for readability purposes, and also to make
the display reasonable in rustdoc.
2017-10-21 18:54:21 -04:00
Andrew Gallant
a9f41405c0
deps: remove winapi and kernel32
These are extraneous at this point. The Windows specific logic is now
encapsulated in the same-file crate.
2.0.0
2017-10-21 08:19:18 -04:00
Andrew Gallant
99fe05638d doc: bump version number to 2 2017-10-21 08:10:18 -04:00
Andrew Gallant
bfd917fdfd deps: upgrade to same-file 1.0 2017-10-21 08:10:18 -04:00
Andrew Gallant
3d4c9f7eca symlinks: optimize check loop on Windows
Broadly speaking, this commit is an attempt to fix this issue:
https://github.com/BurntSushi/ripgrep/issues/633

It was reported that symlink checking was taking a long amount of time,
and that one possible way to fix this was to reduce number of times a
file descriptor is opened. In this commit, we amortize opening file
descriptors by keeping a file handle open for each ancestor in the
directory tree. We also open a handle for the candidate file path at
most once, instead of once every iteration.

Note that we only perform this optimization on Windows, where opening a
file handle seems inordinately expensive. In particular, this now causes
us to potentially open more file descriptors than the limit set by the
user, which only happens when following symbolic links. We document this
behavior.
2017-10-21 08:10:18 -04:00
Andrew Gallant
5ce6b10716 style: switch from try! to ? 2017-10-21 08:10:18 -04:00
Andrew Gallant
2b4e508c75 doc: touchups 2017-10-21 08:10:18 -04:00
Andrew Gallant
a5de1ec0c8 unix: actually export DirEntryExt 2017-10-21 08:10:18 -04:00
Andrew Gallant
45d2f69885 formatting: misc and wrap to 80 cols 2017-10-21 08:10:18 -04:00
Andrew Gallant
8a18c8ad52 ci: bump to Rust 1.17 2017-10-21 08:10:18 -04:00
Andrew Gallant
9c4adadc4f symlink: rename symbolic_link to symlink
Fixes #80
2017-10-21 08:10:18 -04:00
Andrew Gallant
bc0ff47394 examples: upgrade to docopt 0.8 2017-10-21 08:10:18 -04:00
Andrew Gallant
f49cb038ac
fix formatting 2017-10-07 08:21:18 -04:00
Niv Kaminer
64e50c8860 add io_error to inspect the underlying io::Error 2017-10-07 07:48:18 -04:00
Alex Gurganus
364e2323ef Duplicate rust beta being run, should be nightly 2017-10-05 06:43:51 -04:00
opilarium
5be43be864 Revert changes in README 2017-09-30 08:22:58 -04:00
opilarium
f1f9a35f29 executing try_main function is useless in no_run blocks 2017-09-30 08:22:58 -04:00
opilarium
13fdfb4751 no_run attribute instead of rust,no_run
rust syntax is by default
2017-09-30 08:22:58 -04:00
opilarium
fcbb831799 text annotation is better 2017-09-30 08:22:58 -04:00
Jérémie Lawson
c4af8e6173 Use doc from std::os::unix::fs::DirEntryExt for trait walkdir::unix::DirEntryExt.
Moved trait implementation for DirEntry in module unix.
2017-08-03 18:52:10 -04:00
Ashley Mannix
9d55d29fcb Move DirEntry::ino method to an extension trait
Fixes #46
2017-08-03 18:52:10 -04:00
Jérémie Lawson
107750f24e Make WalkDir Send + Sync
Fixes #41
2017-08-03 18:46:26 -04:00
Thayne McCombs
079d1456eb Derive Debug for public structs
Fixes #34
2017-07-31 07:08:59 -04:00
Tshepang Lekhonkhobe
a4cc6e88e7 doc: do not repeat the efficient-ness of it all
Also, define 'efficient'
2017-07-24 18:47:17 -04:00
Josh Holmer
d28c399997 Document why unwraps won't fail 2017-07-21 08:04:52 -04:00
Alisha
3cc8e9ecc9 Correct walkdir docs 2017-07-17 08:25:19 -04:00
Ashley
f21855c5e3 Add osx build to .travis.yml (#72)
Add osx build to .travis.yml
2017-07-17 08:24:55 -04:00
Ashley
2ca0b13040 Added links to documentation (#71) 2017-07-17 08:23:47 -04:00
Jérémie Lawson
86238d6dde Removed is_same_file deprecated function. 2017-07-15 13:09:58 -04:00
Jérémie Lawson
f4de7b969a Remove re-export of is_same_file
Added a wrapper around this function that is deprecated.
Fixes #43.
2017-07-15 13:09:58 -04:00
Andy Gauge
378cb0742e Extended documentation to include Errors section for Iter (Iterator::next()), FilterEntry (Iterator::next()), and DirEntry::metadata() 2017-07-15 12:58:20 -04:00
Andy Gauge
f216fcb1e5 Added links to .into_iter() and .filter_entry() into respective Types. 2017-07-15 12:56:09 -04:00
Jakub Chłapiński
71ceae7fc0 WalkDir sorter should accept whole dir entries instead of just file names (#70)
change sort_by types

This changes the sort_by comparator function to accept a pair
of `&DirEntry`s, which permits the caller more flexibility with
sorting.

Fixes #44, Fixes #45
2017-07-15 12:54:56 -04:00
meven
009be825aa Add links to other walkdir items in WalkDirIterator docs (#73) 2017-07-15 12:49:46 -04:00
Alisha Aneja
c55dc9f4d5 Add links to other walkdir items in WalkDir docs
Fixes #29
2017-07-01 09:05:06 -04:00
Martin Sehnoutka
938b0fa064 Use ? in docs instead of unwrapping
Fixes: #25
2017-06-30 06:49:41 -04:00
Jonathan Soo
4e4c9c4f58 add example for contents_first
Fixes #26
2017-06-29 10:21:28 -04:00
Yufeng Wang
532e56d211 point to IntoIter's filter_entry instead 2017-06-29 09:35:26 -04:00