Skip to content

Commit 13d8a56

Browse files
authored
Rollup merge of rust-lang#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`````
2 parents 3b142cc + e8dcc02 commit 13d8a56

File tree

1 file changed

+5
-0
lines changed
  • library/std/src/sys/wasi/ext

1 file changed

+5
-0
lines changed

library/std/src/sys/wasi/ext/fs.rs

+5
Original file line numberDiff line numberDiff line change
@@ -400,6 +400,8 @@ pub trait MetadataExt {
400400
fn ino(&self) -> u64;
401401
/// Returns the `st_nlink` field of the internal `filestat_t`
402402
fn nlink(&self) -> u64;
403+
/// Returns the `st_size` field of the internal `filestat_t`
404+
fn size(&self) -> u64;
403405
/// Returns the `st_atim` field of the internal `filestat_t`
404406
fn atim(&self) -> u64;
405407
/// Returns the `st_mtim` field of the internal `filestat_t`
@@ -418,6 +420,9 @@ impl MetadataExt for fs::Metadata {
418420
fn nlink(&self) -> u64 {
419421
self.as_inner().as_wasi().nlink
420422
}
423+
fn size(&self) -> u64 {
424+
self.as_inner().as_wasi().size
425+
}
421426
fn atim(&self) -> u64 {
422427
self.as_inner().as_wasi().atim
423428
}

0 commit comments

Comments
 (0)