aboutsummaryrefslogtreecommitdiffhomepage
path: root/crates/shirabe-php-shim/src
diff options
context:
space:
mode:
authornsfisis <nsfisis@gmail.com>2026-06-20 19:39:32 +0900
committernsfisis <nsfisis@gmail.com>2026-06-20 19:39:32 +0900
commit5488b18fd0387d655192350011f331dfda03ebba (patch)
tree4db27902e6f5da5543599ba33dade1da7b1e65fa /crates/shirabe-php-shim/src
parent1f4addc0c016eaf0fd953fd10995d481ea7db74b (diff)
downloadphp-shirabe-5488b18fd0387d655192350011f331dfda03ebba.tar.gz
php-shirabe-5488b18fd0387d655192350011f331dfda03ebba.tar.zst
php-shirabe-5488b18fd0387d655192350011f331dfda03ebba.zip
feat(php-shim): implement is_writable via filesystem metadata
Replace the todo!() with a std-only check on the path's permission bits. A TODO notes this approximates PHP's access(2)/W_OK and can diverge for files the current user does not own; to be refined with a syscall crate. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Diffstat (limited to 'crates/shirabe-php-shim/src')
-rw-r--r--crates/shirabe-php-shim/src/lib.rs8
1 files changed, 7 insertions, 1 deletions
diff --git a/crates/shirabe-php-shim/src/lib.rs b/crates/shirabe-php-shim/src/lib.rs
index 08fe361..d75c1aa 100644
--- a/crates/shirabe-php-shim/src/lib.rs
+++ b/crates/shirabe-php-shim/src/lib.rs
@@ -1457,8 +1457,14 @@ pub fn file_exists(_path: &str) -> bool {
std::path::Path::new(_path).exists()
}
+// TODO(phase-c): PHP's is_writable() resolves to access(2) with W_OK, honoring the effective
+// user/group and ACLs. This std-only approximation only inspects the permission bits, so it can
+// diverge for files the current user does not own. Refine with a syscall (libc/rustix) crate later.
pub fn is_writable(_path: &str) -> bool {
- todo!()
+ match std::fs::metadata(_path) {
+ Ok(meta) => !meta.permissions().readonly(),
+ Err(_) => false,
+ }
}
pub fn unlink(_path: &str) -> bool {