From dfd98ce4b227a3a14dc913c669bee4f077a65178 Mon Sep 17 00:00:00 2001 From: nsfisis Date: Sun, 9 Aug 2026 09:34:34 +0900 Subject: refactor(php-shim): make the fs mutators return Result mkdir, rmdir, unlink and symlink each had a bool version and a _result twin returning the io::Error, which left two names for one call. Keep only the Result form and let the callers that want a boolean spell out .is_ok(). Call sites that discard the outcome, as their PHP originals do, are unchanged. Co-Authored-By: Claude Opus 5 (1M context) --- crates/shirabe-php-shim/src/fs.rs | 24 ++++-------------------- 1 file changed, 4 insertions(+), 20 deletions(-) (limited to 'crates/shirabe-php-shim/src/fs.rs') diff --git a/crates/shirabe-php-shim/src/fs.rs b/crates/shirabe-php-shim/src/fs.rs index eae41dda..bd5e650a 100644 --- a/crates/shirabe-php-shim/src/fs.rs +++ b/crates/shirabe-php-shim/src/fs.rs @@ -834,11 +834,7 @@ pub fn filemtime(_filename: impl AsRef) -> Option { .map(|d| d.as_secs() as i64) } -pub fn unlink(path: impl AsRef) -> bool { - unlink_result(path).is_ok() -} - -pub fn unlink_result(path: impl AsRef) -> Result<(), std::io::Error> { +pub fn unlink(path: impl AsRef) -> Result<(), std::io::Error> { std::fs::remove_file(path) } @@ -968,11 +964,7 @@ pub fn umask() -> u32 { previous.bits() as u32 } -pub fn mkdir(_pathname: impl AsRef, _mode: u32, _recursive: bool) -> bool { - mkdir_result(_pathname, _mode, _recursive).is_ok() -} - -pub fn mkdir_result( +pub fn mkdir( pathname: impl AsRef, mode: u32, recursive: bool, @@ -984,11 +976,7 @@ pub fn mkdir_result( builder.create(pathname.as_ref()) } -pub fn rmdir(dir: impl AsRef) -> bool { - rmdir_result(dir).is_ok() -} - -pub fn rmdir_result(dir: impl AsRef) -> Result<(), std::io::Error> { +pub fn rmdir(dir: impl AsRef) -> Result<(), std::io::Error> { std::fs::remove_dir(dir) } @@ -1029,11 +1017,7 @@ pub fn ftruncate(stream: &PhpResource, size: i64) -> bool { } } -pub fn symlink(_target: impl AsRef, _link: impl AsRef) -> bool { - symlink_result(_target, _link).is_ok() -} - -pub fn symlink_result( +pub fn symlink( target: impl AsRef, link: impl AsRef, ) -> Result<(), std::io::Error> { -- cgit v1.3.1-4-g156e