add: metadata to filetime conversion
@@ -20,7 +20,8 @@ pub struct FileMetadata {
mtime: Option<(i64, u32)>,
}
-// TODO: add way to get std::fs::Permissions out of this, or maybe some libc like type?
+// TODO: add way to get std::fs::Permissions out of this, or maybe some libc like type? or
+// filetime::FileTime.
impl FileMetadata {
/// Returns the full file mode, if one has been specified.
///
@@ -42,6 +43,11 @@ impl FileMetadata {
pub fn mtime(&self) -> Option<(i64, u32)> {
self.mtime
}
+
+ #[cfg(feature = "filetime")]
+ pub fn mtime_as_filetime(&self) -> Option<filetime::FileTime> {
+ self.mtime().map(|(seconds, nanos)| filetime::FileTime::from_unix_time(seconds, nanos))
+ }
}
impl<'a> From<&'a UnixFs<'_>> for FileMetadata {
