From 2936cb809da433a92f267f3bc232d88ed4e315ac Mon Sep 17 00:00:00 2001 From: nsfisis Date: Sat, 15 Aug 2026 14:30:43 +0900 Subject: refactor(php-shim): drop the unused opendir directory handle PhpDirHandle recorded the opened path and nothing else, and its only caller asked just whether the open had succeeded. A resource type that has to gain readdir and closedir before it means anything is worse than the std::fs::read_dir call it wraps, so Filesystem::isReadable now makes that call directly. Co-Authored-By: Claude Opus 5 (1M context) --- crates/shirabe-php-shim/src/fs.rs | 17 ----------------- crates/shirabe/src/util/filesystem.rs | 3 +-- 2 files changed, 1 insertion(+), 19 deletions(-) diff --git a/crates/shirabe-php-shim/src/fs.rs b/crates/shirabe-php-shim/src/fs.rs index 296f8f4a..1bb1379a 100644 --- a/crates/shirabe-php-shim/src/fs.rs +++ b/crates/shirabe-php-shim/src/fs.rs @@ -1056,23 +1056,6 @@ pub fn sys_get_temp_dir() -> String { std::env::temp_dir().to_string_lossy().into_owned() } -// A directory-handle resource. This is a distinct resource kind from the byte streams modeled by -// PhpResource; readdir/closedir have no callers yet, so it only records the opened path. -// TODO(php-semantics): give it real readdir/closedir behavior (cursor over the entries) when needed. -#[derive(Debug)] -pub struct PhpDirHandle { - pub path: std::path::PathBuf, -} - -pub fn opendir(path: impl AsRef) -> Option { - let path = path.as_ref(); - // opendir succeeds iff the path is a readable directory. - std::fs::read_dir(path).ok()?; - Some(PhpDirHandle { - path: path.to_path_buf(), - }) -} - pub fn pathinfo(path: &str, option: i64) -> String { match option { PATHINFO_DIRNAME => dirname(path), diff --git a/crates/shirabe/src/util/filesystem.rs b/crates/shirabe/src/util/filesystem.rs index 6cb33385..066b1981 100644 --- a/crates/shirabe/src/util/filesystem.rs +++ b/crates/shirabe/src/util/filesystem.rs @@ -841,8 +841,7 @@ impl Filesystem { } if is_dir(path) { - return Silencer::call(|| Ok(shirabe_php_shim::opendir(path).is_some())) - .unwrap_or(false); + return Silencer::call(|| Ok(std::fs::read_dir(path).is_ok())).unwrap_or(false); } // assume false otherwise -- cgit v1.3.1-4-g156e