about summary refs log tree commit diff
diff options
context:
space:
mode:
authorDan Gohman <dev@sunfishcode.online>2021-02-22 14:42:59 -0800
committerDan Gohman <dev@sunfishcode.online>2021-02-22 14:42:59 -0800
commite8dcc02dc5bb8ee26c22d67efa4ede281927e5cb (patch)
treeb4450a9b9a1344c3abf7c6355e239461b10c2a8c
parent178108bf81606a0e25b1066568c2b8c8e0648617 (diff)
downloadrust-e8dcc02dc5bb8ee26c22d67efa4ede281927e5cb.tar.gz
rust-e8dcc02dc5bb8ee26c22d67efa4ede281927e5cb.zip
Add a `size()` function to WASI's `MetadataExt`.
WASI's `filestat` type includes a size field, so expose it in
`MetadataExt` via a `size()` function, similar to the corresponding Unix
function.
-rw-r--r--library/std/src/sys/wasi/ext/fs.rs5
1 files changed, 5 insertions, 0 deletions
diff --git a/library/std/src/sys/wasi/ext/fs.rs b/library/std/src/sys/wasi/ext/fs.rs
index a8da003d550..1dc7983f188 100644
--- a/library/std/src/sys/wasi/ext/fs.rs
+++ b/library/std/src/sys/wasi/ext/fs.rs
@@ -397,6 +397,8 @@ pub trait MetadataExt {
     fn ino(&self) -> u64;
     /// Returns the `st_nlink` field of the internal `filestat_t`
     fn nlink(&self) -> u64;
+    /// Returns the `st_size` field of the internal `filestat_t`
+    fn size(&self) -> u64;
     /// Returns the `st_atim` field of the internal `filestat_t`
     fn atim(&self) -> u64;
     /// Returns the `st_mtim` field of the internal `filestat_t`
@@ -415,6 +417,9 @@ impl MetadataExt for fs::Metadata {
     fn nlink(&self) -> u64 {
         self.as_inner().as_wasi().nlink
     }
+    fn size(&self) -> u64 {
+        self.as_inner().as_wasi().size
+    }
     fn atim(&self) -> u64 {
         self.as_inner().as_wasi().atim
     }