@@ -146,16 +146,17 @@ impl Iterator for ReadDir {
146
146
fn next ( & mut self ) -> Option < io:: Result < DirEntry > > {
147
147
loop {
148
148
let start = self . i ;
149
- while self . i < self . data . len ( ) {
150
- let i = self . i ;
149
+ let mut i = self . i ;
150
+ while i < self . data . len ( ) {
151
151
self . i += 1 ;
152
152
if self . data [ i] == b'\n' {
153
153
break ;
154
154
}
155
+ i += 1 ;
155
156
}
156
157
if start < self . i {
157
158
let ret = DirEntry {
158
- name : self . data [ start .. self . i ] . to_owned ( ) . into_boxed_slice ( ) ,
159
+ name : self . data [ start .. i] . to_owned ( ) . into_boxed_slice ( ) ,
159
160
root : self . root . clone ( )
160
161
} ;
161
162
if ret. name_bytes ( ) != b"." && ret. name_bytes ( ) != b".." {
@@ -182,7 +183,7 @@ impl DirEntry {
182
183
}
183
184
184
185
pub fn file_type ( & self ) -> io:: Result < FileType > {
185
- stat ( & self . path ( ) ) . map ( |m| m. file_type ( ) )
186
+ lstat ( & self . path ( ) ) . map ( |m| m. file_type ( ) )
186
187
}
187
188
188
189
fn name_bytes ( & self ) -> & [ u8 ] {
@@ -367,7 +368,8 @@ impl fmt::Debug for File {
367
368
368
369
pub fn readdir ( p : & Path ) -> io:: Result < ReadDir > {
369
370
let root = Arc :: new ( p. to_path_buf ( ) ) ;
370
- let options = OpenOptions :: new ( ) ;
371
+ let mut options = OpenOptions :: new ( ) ;
372
+ options. read ( true ) ;
371
373
let fd = File :: open ( p, & options) ?;
372
374
let mut data = Vec :: new ( ) ;
373
375
fd. read_to_end ( & mut data) ?;
@@ -431,7 +433,8 @@ pub fn link(_src: &Path, _dst: &Path) -> io::Result<()> {
431
433
432
434
pub fn stat ( p : & Path ) -> io:: Result < FileAttr > {
433
435
let mut stat: stat = stat:: default ( ) ;
434
- let options = OpenOptions :: new ( ) ;
436
+ let mut options = OpenOptions :: new ( ) ;
437
+ options. read ( true ) ;
435
438
let file = File :: open ( p, & options) ?;
436
439
cvt ( fstat ( file. 0 . raw ( ) , & mut stat) ) ?;
437
440
Ok ( FileAttr { stat : stat } )
@@ -442,7 +445,8 @@ pub fn lstat(p: &Path) -> io::Result<FileAttr> {
442
445
}
443
446
444
447
pub fn canonicalize ( p : & Path ) -> io:: Result < PathBuf > {
445
- let options = OpenOptions :: new ( ) ;
448
+ let mut options = OpenOptions :: new ( ) ;
449
+ options. read ( true ) ;
446
450
let file = File :: open ( p, & options) ?;
447
451
file. path ( )
448
452
}
0 commit comments