aboutsummaryrefslogtreecommitdiffhomepage
path: root/crates/shirabe-php-shim/src/fs.rs
diff options
context:
space:
mode:
Diffstat (limited to 'crates/shirabe-php-shim/src/fs.rs')
-rw-r--r--crates/shirabe-php-shim/src/fs.rs13
1 files changed, 9 insertions, 4 deletions
diff --git a/crates/shirabe-php-shim/src/fs.rs b/crates/shirabe-php-shim/src/fs.rs
index 0006020a..26ea1fdf 100644
--- a/crates/shirabe-php-shim/src/fs.rs
+++ b/crates/shirabe-php-shim/src/fs.rs
@@ -189,10 +189,15 @@ impl RecursiveIteratorFileInfo {
self.path.to_string_lossy().into_owned()
}
- pub fn get_size(&self) -> i64 {
- std::fs::metadata(&self.path)
- .map(|m| m.len() as i64)
- .unwrap_or(0)
+ pub fn get_size(&self) -> anyhow::Result<i64> {
+ match filesize(&self.path) {
+ Some(size) => Ok(size),
+ None => Err(crate::RuntimeException::new(format!(
+ "SplFileInfo::getSize(): stat failed for {}",
+ self.path.display()
+ ))
+ .into()),
+ }
}
fn sub_pathname(&self) -> String {