aboutsummaryrefslogtreecommitdiffhomepage
path: root/crates
diff options
context:
space:
mode:
authornsfisis <nsfisis@gmail.com>2026-08-15 14:30:43 +0900
committernsfisis <nsfisis@gmail.com>2026-08-15 14:31:02 +0900
commit2936cb809da433a92f267f3bc232d88ed4e315ac (patch)
treee5f74f7ee4abb9ec3d01e143ca5cf51f03c6a2bf /crates
parentf1edda70e5eba2f7db36ea17bc7a4588bcd8d2fc (diff)
downloadphp-shirabe-2936cb809da433a92f267f3bc232d88ed4e315ac.tar.gz
php-shirabe-2936cb809da433a92f267f3bc232d88ed4e315ac.tar.zst
php-shirabe-2936cb809da433a92f267f3bc232d88ed4e315ac.zip
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) <noreply@anthropic.com>
Diffstat (limited to 'crates')
-rw-r--r--crates/shirabe-php-shim/src/fs.rs17
-rw-r--r--crates/shirabe/src/util/filesystem.rs3
2 files changed, 1 insertions, 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<std::path::Path>) -> Option<PhpDirHandle> {
- 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