aboutsummaryrefslogtreecommitdiffhomepage
path: root/crates/shirabe/src/package
diff options
context:
space:
mode:
authornsfisis <nsfisis@gmail.com>2026-08-06 03:46:41 +0900
committernsfisis <nsfisis@gmail.com>2026-08-06 03:46:41 +0900
commit92d2199afcecd0056e82d2559700769715401ef0 (patch)
treeb9d65620db53bc19f800247660e560f3f8775217 /crates/shirabe/src/package
parent27e81d5e5ca0a89eb176a65b1d9f186658b16f50 (diff)
downloadphp-shirabe-92d2199afcecd0056e82d2559700769715401ef0.tar.gz
php-shirabe-92d2199afcecd0056e82d2559700769715401ef0.tar.zst
php-shirabe-92d2199afcecd0056e82d2559700769715401ef0.zip
refactor(php-shim): take filesystem paths as impl AsRef<Path>
The shim's filesystem entry points took `&str` even though each one resolves to a local path through `std::fs` or a syscall, so callers holding a `PathBuf` had to stringify it at the call site. They now take `impl AsRef<Path>`, the form `file_exists`, `is_dir`, `unlink` and the rest of the already-converted set use. `Phar`, `PharData` and `ZipArchive` keep their archive path as a `PathBuf`. `PharData::compress` names the compressed sibling by appending the suffix to the file name rather than formatting the path into a `String`. Arguments PHP resolves through a stream wrapper (`fopen`, `file_put_contents`, `include`) still take `&str`, as do the byte-string operations (`dirname`, `basename`, `pathinfo`) and archive-internal entry names, which are `/`-joined logical names rather than OS paths. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Diffstat (limited to 'crates/shirabe/src/package')
-rw-r--r--crates/shirabe/src/package/archiver/zip_archiver.rs7
-rw-r--r--crates/shirabe/src/package/locker.rs2
2 files changed, 3 insertions, 6 deletions
diff --git a/crates/shirabe/src/package/archiver/zip_archiver.rs b/crates/shirabe/src/package/archiver/zip_archiver.rs
index bf0144fb..186d76c7 100644
--- a/crates/shirabe/src/package/archiver/zip_archiver.rs
+++ b/crates/shirabe/src/package/archiver/zip_archiver.rs
@@ -74,15 +74,12 @@ impl ArchiverInterface for ZipArchiver {
if filepath.is_dir() {
zip.add_empty_dir(&relative_path.to_string_lossy());
} else {
- zip.add_file(
- &filepath.to_string_lossy(),
- &relative_path.to_string_lossy(),
- );
+ zip.add_file(&filepath, &relative_path.to_string_lossy());
}
// setExternalAttributesName() is only available with libzip 0.11.2 or above
if method_exists(&PhpMixed::Null, "setExternalAttributesName") {
- let perms = fileperms(&filepath.to_string_lossy());
+ let perms = fileperms(&filepath);
zip.set_external_attributes_name(
&relative_path.to_string_lossy(),
ZipArchive::OPSYS_UNIX,
diff --git a/crates/shirabe/src/package/locker.rs b/crates/shirabe/src/package/locker.rs
index b7d8ba7a..d2d1b109 100644
--- a/crates/shirabe/src/package/locker.rs
+++ b/crates/shirabe/src/package/locker.rs
@@ -807,7 +807,7 @@ impl Locker {
if path.is_none() {
return Ok(None);
}
- let path = realpath(&path.unwrap());
+ let path = realpath(path.unwrap());
let source_type = package.get_source_type();
let mut datetime: Option<chrono::DateTime<chrono::Utc>> = None;