aboutsummaryrefslogtreecommitdiffhomepage
path: root/crates/shirabe
diff options
context:
space:
mode:
authornsfisis <nsfisis@gmail.com>2026-08-16 10:29:50 +0900
committernsfisis <nsfisis@gmail.com>2026-08-16 10:29:50 +0900
commit45f0ae17ce5528af2af66fd681e88fe4a4a7cd6e (patch)
treedb3625fe15fa1ff726f8d1cdaff403e82912b013 /crates/shirabe
parent3665099cd2ed5bbbc89201d240755218e16f19e1 (diff)
downloadphp-shirabe-45f0ae17ce5528af2af66fd681e88fe4a4a7cd6e.tar.gz
php-shirabe-45f0ae17ce5528af2af66fd681e88fe4a4a7cd6e.tar.zst
php-shirabe-45f0ae17ce5528af2af66fd681e88fe4a4a7cd6e.zip
refactor(php-shim): give fstat and lstat a typed FileStat result
fstat and lstat now return Option<FileStat> instead of a PhpMixed array, so Platform::is_tty and Filesystem::is_junction read `mode` as a field. The array carried each of the 13 values twice — once under its numeric index and once under its name — which no caller relied on, and building it spelled the field list out four times. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Diffstat (limited to 'crates/shirabe')
-rw-r--r--crates/shirabe/src/util/filesystem.rs7
-rw-r--r--crates/shirabe/src/util/platform.rs6
2 files changed, 4 insertions, 9 deletions
diff --git a/crates/shirabe/src/util/filesystem.rs b/crates/shirabe/src/util/filesystem.rs
index 532c96dd..44dddb8c 100644
--- a/crates/shirabe/src/util/filesystem.rs
+++ b/crates/shirabe/src/util/filesystem.rs
@@ -1021,11 +1021,10 @@ impl Filesystem {
let stat = lstat(junction);
// S_ISDIR test (S_IFDIR is 0x4000, S_IFMT is 0xF000 bitmask)
- if let Some(arr) = stat {
- let mode = arr.get("mode").and_then(|v| v.as_int()).unwrap_or(0);
- return 0x4000 != (mode & 0xF000);
+ match stat {
+ Some(stat) => 0x4000 != (stat.mode & 0xF000),
+ None => false,
}
- false
}
/// Removes a Windows NTFS junction.
diff --git a/crates/shirabe/src/util/platform.rs b/crates/shirabe/src/util/platform.rs
index 2cef4109..f45294d5 100644
--- a/crates/shirabe/src/util/platform.rs
+++ b/crates/shirabe/src/util/platform.rs
@@ -296,11 +296,7 @@ impl Platform {
};
// Check if formatted mode is S_IFCHR
- if let Some(mode) = stat.get("mode").and_then(|v| v.as_int()) {
- return 0o020000 == (mode & 0o170000);
- }
-
- false
+ 0o020000 == (stat.mode & 0o170000)
}
/// Whether the current command is for bash completion