File tree Expand file tree Collapse file tree 2 files changed +33
-0
lines changed Expand file tree Collapse file tree 2 files changed +33
-0
lines changed Original file line number Diff line number Diff line change @@ -206,11 +206,36 @@ impl<S> AsyncFile<S>
206206where
207207 S : AsyncSessionStream + Send + Sync + ' static ,
208208{
209+ pub async fn setstat ( & mut self , stat : FileStat ) -> Result < ( ) , Error > {
210+ self . stream
211+ . rw_with ( || self . inner . setstat ( stat. clone ( ) ) , & self . sess )
212+ . await
213+ }
214+
215+ pub async fn stat ( & mut self ) -> Result < FileStat , Error > {
216+ self . stream . rw_with ( || self . inner . stat ( ) , & self . sess ) . await
217+ }
218+
219+ pub async fn statvfs ( & mut self ) -> Result < libssh2_sys:: LIBSSH2_SFTP_STATVFS , Error > {
220+ self . stream
221+ . rw_with ( || self . inner . statvfs ( ) , & self . sess )
222+ . await
223+ }
224+
209225 pub async fn readdir ( & mut self ) -> Result < ( PathBuf , FileStat ) , Error > {
210226 self . stream
211227 . rw_with ( || self . inner . readdir ( ) , & self . sess )
212228 . await
213229 }
230+
231+ pub async fn fsync ( & mut self ) -> Result < ( ) , Error > {
232+ self . stream . rw_with ( || self . inner . fsync ( ) , & self . sess ) . await
233+ }
234+
235+ #[ doc( hidden) ]
236+ pub async fn close ( & mut self ) -> Result < ( ) , Error > {
237+ self . stream . rw_with ( || self . inner . close ( ) , & self . sess ) . await
238+ }
214239}
215240
216241mod impl_futures_util {
Original file line number Diff line number Diff line change @@ -43,8 +43,16 @@ async fn __run__session__sftp<S: AsyncSessionStream + Send + Sync + 'static>(
4343 let remote_path = PathBuf :: from ( "/tmp" ) . join ( format ! ( "sftp_{}" , Uuid :: new_v4( ) ) ) ;
4444
4545 sftp. create ( & remote_path) . await ?;
46+
4647 let file_stat = sftp. stat ( & remote_path) . await ?;
4748 println ! ( "sftp file_stat:{:?}" , file_stat) ;
49+
50+ let mut sftp_file = sftp. open ( & remote_path) . await ?;
51+ let file_stat_for_file = sftp_file. stat ( ) . await ?;
52+ println ! ( "sftp file_stat_for_file:{:?}" , file_stat_for_file) ;
53+ sftp_file. close ( ) . await ?;
54+ assert_eq ! ( file_stat, file_stat_for_file) ;
55+
4856 sftp. unlink ( & remote_path) . await ?;
4957
5058 let list = sftp. readdir ( & PathBuf :: from ( "/" ) ) . await ?;
You can’t perform that action at this time.
0 commit comments