File tree Expand file tree Collapse file tree 1 file changed +12
-4
lines changed Expand file tree Collapse file tree 1 file changed +12
-4
lines changed Original file line number Diff line number Diff line change @@ -211,18 +211,26 @@ pub fn open<P: AsRef<Path>>(path: P) -> Result<File> {
211
211
File :: open ( path) . with_context ( || format ! ( "failed to open file `{}`" , path. display( ) ) )
212
212
}
213
213
214
+ /// Returns the metadata of the path (follows symlinks).
215
+ pub fn metadata ( path : & Path ) -> Result < fs:: Metadata > {
216
+ fs:: metadata ( path) . with_context ( || format ! ( "failed to stat `{}`" , path. display( ) ) )
217
+ }
218
+
219
+ /// Returns the metadata of the path (does not follow symlinks).
220
+ pub fn symlink_metadata ( path : & Path ) -> Result < fs:: Metadata > {
221
+ fs:: symlink_metadata ( path) . with_context ( || format ! ( "failed to lstat `{}`" , path. display( ) ) )
222
+ }
223
+
214
224
/// Returns the last modification time of a file.
215
225
pub fn mtime ( path : & Path ) -> Result < FileTime > {
216
- let meta =
217
- fs:: metadata ( path) . with_context ( || format ! ( "failed to stat `{}`" , path. display( ) ) ) ?;
226
+ let meta = metadata ( path) ?;
218
227
Ok ( FileTime :: from_last_modification_time ( & meta) )
219
228
}
220
229
221
230
/// Returns the maximum mtime of the given path, recursing into
222
231
/// subdirectories, and following symlinks.
223
232
pub fn mtime_recursive ( path : & Path ) -> Result < FileTime > {
224
- let meta =
225
- fs:: metadata ( path) . with_context ( || format ! ( "failed to stat `{}`" , path. display( ) ) ) ?;
233
+ let meta = metadata ( path) ?;
226
234
if !meta. is_dir ( ) {
227
235
return Ok ( FileTime :: from_last_modification_time ( & meta) ) ;
228
236
}
You can’t perform that action at this time.
0 commit comments