aboutsummaryrefslogtreecommitdiffhomepage
path: root/crates/shirabe/src/util
diff options
context:
space:
mode:
authornsfisis <nsfisis@gmail.com>2026-08-09 09:34:34 +0900
committernsfisis <nsfisis@gmail.com>2026-08-09 09:34:34 +0900
commitdfd98ce4b227a3a14dc913c669bee4f077a65178 (patch)
treedef0558566319a18ffbcdc4eb4e5175e3c6c9bb0 /crates/shirabe/src/util
parentd2a28f8c07b0aa713be338005c6153011d70f24b (diff)
downloadphp-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/src/util')
-rw-r--r--crates/shirabe/src/util/filesystem.rs14
1 files changed, 7 insertions, 7 deletions
diff --git a/crates/shirabe/src/util/filesystem.rs b/crates/shirabe/src/util/filesystem.rs
index 2c4cbcc6..925cb38a 100644
--- a/crates/shirabe/src/util/filesystem.rs
+++ b/crates/shirabe/src/util/filesystem.rs
@@ -240,7 +240,7 @@ impl Filesystem {
}
if is_link(directory) {
- return Ok(Some(unlink(directory)));
+ return Ok(Some(unlink(directory).is_ok()));
}
if !is_dir(directory) || !file_exists(directory) {
@@ -328,7 +328,7 @@ impl Filesystem {
.into());
}
- if !mkdir(directory, 0o777, true) {
+ if mkdir(directory, 0o777, true).is_err() {
let e = RuntimeException::new(format!(
"{} does not exist and could not be created: {}",
directory,
@@ -393,12 +393,12 @@ impl Filesystem {
/// Attempts to rmdir a file and in case of failure retries after 350ms on windows
pub fn rmdir(&self, path: impl AsRef<Path>) -> anyhow::Result<bool> {
let path = path.as_ref();
- let mut deleted = rmdir(path);
+ let mut deleted = rmdir(path).is_ok();
if !deleted {
// retry after a bit on windows since it tends to be touchy with mass removals
if Platform::is_windows() {
usleep(350000);
- deleted = rmdir(path);
+ deleted = rmdir(path).is_ok();
}
if !deleted {
@@ -922,10 +922,10 @@ impl Filesystem {
/// symbolic links on windows which link to directories need rmdir instead of unlink
fn unlink_implementation(&self, path: &Path) -> bool {
if Platform::is_windows() && is_dir(path) && is_link(path) {
- return rmdir(path);
+ return rmdir(path).is_ok();
}
- unlink(path)
+ unlink(path).is_ok()
}
/// Creates a relative symlink from $link to $target
@@ -938,7 +938,7 @@ impl Filesystem {
let relative_path = self.find_shortest_path(link, target, false, false);
chdir(dirname(link));
- let result = symlink(&relative_path, link);
+ let result = symlink(&relative_path, link).is_ok();
chdir(&cwd);