Skip to content

Commit e8dcc02

Browse files
committed
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.
1 parent 178108b commit e8dcc02

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

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -397,6 +397,8 @@ pub trait MetadataExt {
397397
fn ino(&self) -> u64;
398398
/// Returns the `st_nlink` field of the internal `filestat_t`
399399
fn nlink(&self) -> u64;
400+
/// Returns the `st_size` field of the internal `filestat_t`
401+
fn size(&self) -> u64;
400402
/// Returns the `st_atim` field of the internal `filestat_t`
401403
fn atim(&self) -> u64;
402404
/// Returns the `st_mtim` field of the internal `filestat_t`
@@ -415,6 +417,9 @@ impl MetadataExt for fs::Metadata {
415417
fn nlink(&self) -> u64 {
416418
self.as_inner().as_wasi().nlink
417419
}
420+
fn size(&self) -> u64 {
421+
self.as_inner().as_wasi().size
422+
}
418423
fn atim(&self) -> u64 {
419424
self.as_inner().as_wasi().atim
420425
}

0 commit comments

Comments
 (0)