File tree Expand file tree Collapse file tree 1 file changed +2
-19
lines changed Expand file tree Collapse file tree 1 file changed +2
-19
lines changed Original file line number Diff line number Diff line change @@ -2033,25 +2033,8 @@ fn gzrewind_error() {
20332033//
20342034// - `Ok(size)` on success.
20352035// - `Err` on error.
2036- fn file_size ( path : & str ) -> Result < usize , ( ) > {
2037- let mut result = Err ( ( ) ) ;
2038- let stat_ptr = unsafe { libc:: calloc ( 1 , core:: mem:: size_of :: < libc:: stat > ( ) as _ ) } ;
2039- if stat_ptr. is_null ( ) {
2040- return result;
2041- }
2042- let ret = unsafe {
2043- libc:: stat (
2044- CString :: new ( path) . unwrap ( ) . as_ptr ( ) ,
2045- stat_ptr. cast :: < libc:: stat > ( ) ,
2046- )
2047- } ;
2048- if ret == 0 {
2049- if let Some ( stat_info) = unsafe { stat_ptr. cast :: < libc:: stat > ( ) . as_ref ( ) } {
2050- result = Ok ( stat_info. st_size as usize ) ;
2051- }
2052- }
2053- unsafe { libc:: free ( stat_ptr) } ;
2054- result
2036+ fn file_size ( path : & str ) -> Result < usize , std:: io:: Error > {
2037+ Ok ( std:: fs:: metadata ( path) ?. len ( ) as usize )
20552038}
20562039
20572040#[ cfg( feature = "gzprintf" ) ]
You can’t perform that action at this time.
0 commit comments