Skip to content

Commit

Permalink
Rollup merge of rust-lang#82421 - sunfishcode:wasi-metadata-size, r=a…
Browse files Browse the repository at this point in the history
…lexcrichton

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```
  • Loading branch information
JohnTitor authored Feb 24, 2021
2 parents 459edd6 + e8dcc02 commit 603332d
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions library/std/src/sys/wasi/ext/fs.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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`
Expand All @@ -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
}
Expand Down

0 comments on commit 603332d

Please sign in to comment.