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 11use ignore:: DirEntry ;
22
3- use std:: { fs, path:: Path } ;
3+ use std:: { fs:: File , io :: Read , path:: Path } ;
44
55/// The default directory filter.
66pub fn filter_dirs ( path : & Path ) -> bool {
@@ -48,9 +48,12 @@ pub fn walk(
4848 skip : impl Send + Sync + ' static + Fn ( & Path ) -> bool ,
4949 f : & mut dyn FnMut ( & DirEntry , & str ) ,
5050) {
51+ let mut contents = Vec :: new ( ) ;
5152 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) {
5457 Ok ( s) => s,
5558 Err ( _) => return , // skip this file
5659 } ;
You can’t perform that action at this time.
0 commit comments