@@ -1033,13 +1033,79 @@ impl ReadDirAllocation {
10331033    } 
10341034} 
10351035
1036+ #[ derive( Debug ,  Clone ,  Copy ,  Eq ,  PartialEq ,  Ord ,  PartialOrd ,  Hash ) ]  
1037+ pub  struct  DirIterationTell  { 
1038+     tell_result :  u32 , 
1039+ } 
1040+ 
10361041pub  struct  ReadDir < ' a ,  ' b ,  S :  driver:: Storage >  { 
10371042    alloc :  RefCell < & ' b  mut  ReadDirAllocation > , 
10381043    fs :  & ' b  Filesystem < ' a ,  S > , 
10391044    #[ cfg( feature = "dir-entry-path" ) ]  
10401045    path :  PathBuf , 
10411046} 
10421047
1048+ impl < ' a ,  ' b ,  S :  driver:: Storage >  ReadDir < ' a ,  ' b ,  S >  { 
1049+     /// Return the position of the directory 
1050+ /// 
1051+ /// The returned offset is only meant to be consumed by seek and may not make 
1052+ /// sense, but does indicate the current position in the directory iteration. 
1053+ /// 
1054+ /// Returns the position of the directory, which can be returned to using [`seek`](Self::seek). 
1055+ pub  fn  tell ( & self )  -> Result < DirIterationTell >  { 
1056+         let  value = unsafe  { 
1057+             ll:: lfs_dir_tell ( 
1058+                 & mut  self . fs . alloc . borrow_mut ( ) . state , 
1059+                 & mut  self . alloc . borrow_mut ( ) . state , 
1060+             ) 
1061+         } ; 
1062+         if  value < 0  { 
1063+             Err ( io:: result_from ( ( ) ,  value) . unwrap_err ( ) ) 
1064+         }  else  { 
1065+             Ok ( DirIterationTell  { 
1066+                 tell_result :  value as  u32 , 
1067+             } ) 
1068+         } 
1069+     } 
1070+ 
1071+     /// Change the position of the directory 
1072+ /// 
1073+ /// The new off must be a value previous returned from [`tell`](Self::tell) and specifies 
1074+ /// an absolute offset in the directory seek. 
1075+ pub  fn  seek ( & mut  self ,  state :  DirIterationTell )  -> Result < DirIterationTell >  { 
1076+         let  value = unsafe  { 
1077+             ll:: lfs_dir_seek ( 
1078+                 & mut  self . fs . alloc . borrow_mut ( ) . state , 
1079+                 & mut  self . alloc . borrow_mut ( ) . state , 
1080+                 state. tell_result , 
1081+             ) 
1082+         } ; 
1083+         if  value < 0  { 
1084+             Err ( io:: result_from ( ( ) ,  value) . unwrap_err ( ) ) 
1085+         }  else  { 
1086+             Ok ( DirIterationTell  { 
1087+                 tell_result :  value as  u32 , 
1088+             } ) 
1089+         } 
1090+     } 
1091+ 
1092+     /// Change the position of the directory to the beginning of the directory 
1093+ pub  fn  rewind ( & mut  self )  -> Result < ( ) >  { 
1094+         let  res = unsafe  { 
1095+             ll:: lfs_dir_rewind ( 
1096+                 & mut  self . fs . alloc . borrow_mut ( ) . state , 
1097+                 & mut  self . alloc . borrow_mut ( ) . state , 
1098+             ) 
1099+         } ; 
1100+ 
1101+         if  res < 0  { 
1102+             Err ( io:: result_from ( ( ) ,  res) . unwrap_err ( ) ) 
1103+         }  else  { 
1104+             Ok ( ( ) ) 
1105+         } 
1106+     } 
1107+ } 
1108+ 
10431109impl < ' a ,  ' b ,  S :  driver:: Storage >  Iterator  for  ReadDir < ' a ,  ' b ,  S >  { 
10441110    type  Item  = Result < DirEntry > ; 
10451111
0 commit comments