File tree Expand file tree Collapse file tree 1 file changed +6
-3
lines changed Expand file tree Collapse file tree 1 file changed +6
-3
lines changed Original file line number Diff line number Diff line change 1
1
use ignore:: DirEntry ;
2
2
3
- use std:: { fs, path:: Path } ;
3
+ use std:: { fs:: File , io :: Read , path:: Path } ;
4
4
5
5
/// The default directory filter.
6
6
pub fn filter_dirs ( path : & Path ) -> bool {
@@ -48,9 +48,12 @@ pub fn walk(
48
48
skip : impl Send + Sync + ' static + Fn ( & Path ) -> bool ,
49
49
f : & mut dyn FnMut ( & DirEntry , & str ) ,
50
50
) {
51
+ let mut contents = Vec :: new ( ) ;
51
52
walk_no_read ( path, skip, & mut |entry| {
52
- let contents = t ! ( fs:: read( entry. path( ) ) , entry. path( ) ) ;
53
- let contents_str = match String :: from_utf8 ( contents) {
53
+ contents. clear ( ) ;
54
+ let mut file = t ! ( File :: open( entry. path( ) ) , entry. path( ) ) ;
55
+ t ! ( file. read_to_end( & mut contents) , entry. path( ) ) ;
56
+ let contents_str = match std:: str:: from_utf8 ( & contents) {
54
57
Ok ( s) => s,
55
58
Err ( _) => return , // skip this file
56
59
} ;
You can’t perform that action at this time.
0 commit comments