about summary refs log tree commit diff
path: root/src/libstd/sys
diff options
context:
space:
mode:
authorSebastian Wicki <gandro@gmx.net>2016-02-21 16:31:56 +0100
committerSebastian Wicki <gandro@gmx.net>2016-02-21 16:35:37 +0100
commit028106c434dfe428d111c3c532f6995e16e26198 (patch)
treeecc9dfb4b9339653fdde2455414ec0e059550990 /src/libstd/sys
parent257fa0f479e6a0fc069710a4c2ea52e551bafe97 (diff)
downloadrust-028106c434dfe428d111c3c532f6995e16e26198.tar.gz
rust-028106c434dfe428d111c3c532f6995e16e26198.zip
Fix `struct stat` usage on NetBSD
Some struct members have a slighty different name on NetBSD. This has been
fixed in the libc crate, but not in libstd.

This also removes `st_spare` from MetadataExt, since it is private field
reserved for future use.
Diffstat (limited to 'src/libstd/sys')
-rw-r--r--src/libstd/sys/unix/fs.rs26
1 files changed, 25 insertions, 1 deletions
diff --git a/src/libstd/sys/unix/fs.rs b/src/libstd/sys/unix/fs.rs
index e8e0a604e55..74393696e5e 100644
--- a/src/libstd/sys/unix/fs.rs
+++ b/src/libstd/sys/unix/fs.rs
@@ -119,7 +119,31 @@ impl FileAttr {
     }
 }
 
-#[cfg(not(any(target_os = "ios", target_os = "macos")))]
+#[cfg(target_os = "netbsd")]
+impl FileAttr {
+    pub fn modified(&self) -> io::Result<SystemTime> {
+        Ok(SystemTime::from(libc::timespec {
+            tv_sec: self.stat.st_mtime as libc::time_t,
+            tv_nsec: self.stat.st_mtimensec as libc::c_long,
+        }))
+    }
+
+    pub fn accessed(&self) -> io::Result<SystemTime> {
+        Ok(SystemTime::from(libc::timespec {
+            tv_sec: self.stat.st_atime as libc::time_t,
+            tv_nsec: self.stat.st_atimensec as libc::c_long,
+        }))
+    }
+
+    pub fn created(&self) -> io::Result<SystemTime> {
+        Ok(SystemTime::from(libc::timespec {
+            tv_sec: self.stat.st_birthtime as libc::time_t,
+            tv_nsec: self.stat.st_birthtimensec as libc::c_long,
+        }))
+    }
+}
+
+#[cfg(not(any(target_os = "ios", target_os = "macos", target_os = "netbsd")))]
 impl FileAttr {
     pub fn modified(&self) -> io::Result<SystemTime> {
         Ok(SystemTime::from(libc::timespec {