diff options
| author | Dylan DPC <dylan.dpc@gmail.com> | 2021-02-27 02:34:28 +0100 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2021-02-27 02:34:28 +0100 |
| commit | d80033f048d88bce20d4785ea7afdd88b4295f35 (patch) | |
| tree | aa0b33e0dde7b6f1050a4c32385b75ff9e878bb4 /library/std/src | |
| parent | f5b68a4444a96f8a2915dfa8b7fc9b641f56bdf2 (diff) | |
| parent | e8dcc02dc5bb8ee26c22d67efa4ede281927e5cb (diff) | |
| download | rust-d80033f048d88bce20d4785ea7afdd88b4295f35.tar.gz rust-d80033f048d88bce20d4785ea7afdd88b4295f35.zip | |
Rollup merge of #82421 - sunfishcode:wasi-metadata-size, r=alexcrichton
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. r? ``````@alexcrichton``````
Diffstat (limited to 'library/std/src')
| -rw-r--r-- | library/std/src/sys/wasi/ext/fs.rs | 5 |
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 66b6caf2512..6472642f034 100644 --- a/library/std/src/sys/wasi/ext/fs.rs +++ b/library/std/src/sys/wasi/ext/fs.rs @@ -400,6 +400,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` @@ -418,6 +420,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 } |
