diff options
| author | nsfisis <nsfisis@gmail.com> | 2026-06-06 21:44:46 +0900 |
|---|---|---|
| committer | nsfisis <nsfisis@gmail.com> | 2026-06-06 21:44:46 +0900 |
| commit | 33550b03c1724fbc8c1c8630c3b03fca1f0c0dc7 (patch) | |
| tree | 5558f28ea897408607fd5008d594017b7ee27210 /crates/shirabe/src/installer | |
| parent | 8bd02532cd04ee12d7595029c206f3dc5ab9dd96 (diff) | |
| download | php-shirabe-33550b03c1724fbc8c1c8630c3b03fca1f0c0dc7.tar.gz php-shirabe-33550b03c1724fbc8c1c8630c3b03fca1f0c0dc7.tar.zst php-shirabe-33550b03c1724fbc8c1c8630c3b03fca1f0c0dc7.zip | |
feat(binary-installer): use file_get_contents with offset and length
Add file_get_contents5 shim supporting use_include_path/context/offset/
length, and wire it into BinaryInstaller to read the first 500 bytes of
the bin file, replacing the offset-less stub and its phase-b TODO.
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Diffstat (limited to 'crates/shirabe/src/installer')
| -rw-r--r-- | crates/shirabe/src/installer/binary_installer.rs | 10 |
1 files changed, 4 insertions, 6 deletions
diff --git a/crates/shirabe/src/installer/binary_installer.rs b/crates/shirabe/src/installer/binary_installer.rs index 64908bf..539201f 100644 --- a/crates/shirabe/src/installer/binary_installer.rs +++ b/crates/shirabe/src/installer/binary_installer.rs @@ -5,8 +5,8 @@ use indexmap::IndexMap; use shirabe_external_packages::composer::pcre::{CaptureKey, Preg}; use shirabe_php_shim::{ PhpMixed, basename, basename_with_suffix, chmod, dirname, fclose, fgets, file_exists, - file_get_contents, file_put_contents, fopen, is_dir, is_file, is_link, realpath, rmdir, substr, - trim, umask, + file_get_contents5, file_put_contents, fopen, is_dir, is_file, is_link, realpath, rmdir, + substr, trim, umask, }; use crate::io::IOInterface; @@ -245,7 +245,6 @@ impl BinaryInstaller { self.filesystem .borrow_mut() .ensure_directory_exists(&self.bin_dir); - // TODO(phase-b): PHP assigns realpath(...) even when realpath returns false self.bin_dir = realpath(&self.bin_dir).unwrap_or_default(); } @@ -294,9 +293,8 @@ impl BinaryInstaller { let bin_dir = ProcessExecutor::escape(&dirname(&bin_path)); let bin_file = basename(&bin_path); - // PHP: file_get_contents($bin, false, null, 0, 500) — limit 500 bytes - // TODO(phase-b): file_get_contents shim does not support offset/maxlen - let bin_contents = file_get_contents(bin).unwrap_or_default(); + let bin_contents = + file_get_contents5(bin, false, PhpMixed::Null, 0, Some(500)).unwrap_or_default(); // For php files, we generate a PHP proxy instead of a shell one, // which allows calling the proxy with a custom php process if let Some(m) = |
