aboutsummaryrefslogtreecommitdiffhomepage
path: root/crates/shirabe/src/package/archiver/zip_archiver.rs
diff options
context:
space:
mode:
authornsfisis <nsfisis@gmail.com>2026-05-17 02:53:53 +0900
committernsfisis <nsfisis@gmail.com>2026-05-17 02:53:53 +0900
commita1c7e6908a26e10f6e1f23a51721664b5e2d838d (patch)
treec575c76f1b43359ed74913da4c6a2636643f1ba0 /crates/shirabe/src/package/archiver/zip_archiver.rs
parent7f606f36fef0c0467c3c0db3d0da33af486dae8a (diff)
downloadphp-shirabe-a1c7e6908a26e10f6e1f23a51721664b5e2d838d.tar.gz
php-shirabe-a1c7e6908a26e10f6e1f23a51721664b5e2d838d.tar.zst
php-shirabe-a1c7e6908a26e10f6e1f23a51721664b5e2d838d.zip
chore(style): cargo fmt
Diffstat (limited to 'crates/shirabe/src/package/archiver/zip_archiver.rs')
-rw-r--r--crates/shirabe/src/package/archiver/zip_archiver.rs35
1 files changed, 22 insertions, 13 deletions
diff --git a/crates/shirabe/src/package/archiver/zip_archiver.rs b/crates/shirabe/src/package/archiver/zip_archiver.rs
index 104c544..ef5b40a 100644
--- a/crates/shirabe/src/package/archiver/zip_archiver.rs
+++ b/crates/shirabe/src/package/archiver/zip_archiver.rs
@@ -1,11 +1,13 @@
//! ref: composer/src/Composer/Package/Archiver/ZipArchiver.php
-use indexmap::IndexMap;
-use shirabe_php_shim::{class_exists, fileperms, method_exists, pack, realpath, PhpMixed, RuntimeException, ZipArchive};
use crate::package::archiver::archivable_files_finder::ArchivableFilesFinder;
use crate::package::archiver::archiver_interface::ArchiverInterface;
use crate::util::filesystem::Filesystem;
use crate::util::platform::Platform;
+use indexmap::IndexMap;
+use shirabe_php_shim::{
+ PhpMixed, RuntimeException, ZipArchive, class_exists, fileperms, method_exists, pack, realpath,
+};
#[derive(Debug)]
pub struct ZipArchiver;
@@ -60,22 +62,29 @@ impl ArchiverInterface for ZipArchiver {
// setExternalAttributesName() is only available with libzip 0.11.2 or above
if method_exists(&PhpMixed::Null, "setExternalAttributesName") {
let perms = fileperms(&filepath);
- zip.set_external_attributes_name(&relative_path, ZipArchive::OPSYS_UNIX, perms << 16);
+ zip.set_external_attributes_name(
+ &relative_path,
+ ZipArchive::OPSYS_UNIX,
+ perms << 16,
+ );
}
}
if zip.close() {
if !std::path::Path::new(&target).exists() {
// create minimal valid ZIP file (Empty Central Directory + End of Central Directory record)
- let eocd = pack("VvvvvVVv", &[
- PhpMixed::Int(0x06054b50), // End of central directory signature
- PhpMixed::Int(0), // Number of this disk
- PhpMixed::Int(0), // Disk where central directory starts
- PhpMixed::Int(0), // Number of central directory records on this disk
- PhpMixed::Int(0), // Total number of central directory records
- PhpMixed::Int(0), // Size of central directory (bytes)
- PhpMixed::Int(0), // Offset of start of central directory
- PhpMixed::Int(0), // Comment length
- ]);
+ let eocd = pack(
+ "VvvvvVVv",
+ &[
+ PhpMixed::Int(0x06054b50), // End of central directory signature
+ PhpMixed::Int(0), // Number of this disk
+ PhpMixed::Int(0), // Disk where central directory starts
+ PhpMixed::Int(0), // Number of central directory records on this disk
+ PhpMixed::Int(0), // Total number of central directory records
+ PhpMixed::Int(0), // Size of central directory (bytes)
+ PhpMixed::Int(0), // Offset of start of central directory
+ PhpMixed::Int(0), // Comment length
+ ],
+ );
std::fs::write(&target, &eocd)?;
}