diff options
| author | nsfisis <nsfisis@gmail.com> | 2026-08-09 09:34:34 +0900 |
|---|---|---|
| committer | nsfisis <nsfisis@gmail.com> | 2026-08-09 09:34:34 +0900 |
| commit | dfd98ce4b227a3a14dc913c669bee4f077a65178 (patch) | |
| tree | def0558566319a18ffbcdc4eb4e5175e3c6c9bb0 /crates/shirabe-php-shim | |
| parent | d2a28f8c07b0aa713be338005c6153011d70f24b (diff) | |
| download | php-shirabe-dfd98ce4b227a3a14dc913c669bee4f077a65178.tar.gz php-shirabe-dfd98ce4b227a3a14dc913c669bee4f077a65178.tar.zst php-shirabe-dfd98ce4b227a3a14dc913c669bee4f077a65178.zip | |
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) <noreply@anthropic.com>
Diffstat (limited to 'crates/shirabe-php-shim')
| -rw-r--r-- | crates/shirabe-php-shim/src/fs.rs | 24 |
1 files changed, 4 insertions, 20 deletions
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<std::path::Path>) -> Option<i64> { .map(|d| d.as_secs() as i64) } -pub fn unlink(path: impl AsRef<std::path::Path>) -> bool { - unlink_result(path).is_ok() -} - -pub fn unlink_result(path: impl AsRef<std::path::Path>) -> Result<(), std::io::Error> { +pub fn unlink(path: impl AsRef<std::path::Path>) -> 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<std::path::Path>, _mode: u32, _recursive: bool) -> bool { - mkdir_result(_pathname, _mode, _recursive).is_ok() -} - -pub fn mkdir_result( +pub fn mkdir( pathname: impl AsRef<std::path::Path>, mode: u32, recursive: bool, @@ -984,11 +976,7 @@ pub fn mkdir_result( builder.create(pathname.as_ref()) } -pub fn rmdir(dir: impl AsRef<std::path::Path>) -> bool { - rmdir_result(dir).is_ok() -} - -pub fn rmdir_result(dir: impl AsRef<std::path::Path>) -> Result<(), std::io::Error> { +pub fn rmdir(dir: impl AsRef<std::path::Path>) -> 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<std::path::Path>, _link: impl AsRef<std::path::Path>) -> bool { - symlink_result(_target, _link).is_ok() -} - -pub fn symlink_result( +pub fn symlink( target: impl AsRef<std::path::Path>, link: impl AsRef<std::path::Path>, ) -> Result<(), std::io::Error> { |
