summaryrefslogtreecommitdiff
path: root/packer
diff options
context:
space:
mode:
authorValentin Popov <valentin@popov.link>2024-01-06 02:48:19 +0300
committerValentin Popov <valentin@popov.link>2024-01-06 02:48:19 +0300
commitcec2ad2c6217dda5ae0b6332ca594930167af8c5 (patch)
tree98a9d420a715279e5432c707cff2eaab6ea87537 /packer
parent58b6314dec29debf8e595f3d75c5818ead648d49 (diff)
downloadfparkan-cec2ad2c6217dda5ae0b6332ca594930167af8c5.tar.xz
fparkan-cec2ad2c6217dda5ae0b6332ca594930167af8c5.zip
Finished the algorithm for packing and unpacking files
Diffstat (limited to 'packer')
-rw-r--r--packer/src/main.rs7
1 files changed, 6 insertions, 1 deletions
diff --git a/packer/src/main.rs b/packer/src/main.rs
index ae4e02a..a5526e3 100644
--- a/packer/src/main.rs
+++ b/packer/src/main.rs
@@ -53,7 +53,7 @@ fn pack(input: String, output: String) {
for (index, item) in list.iter().enumerate() {
// Открываем дескриптор файла
- let path = format!("{}/{}", input, item.name);
+ let path = format!("{}/{}.{}", input, item.name, item.index);
let file = File::open(path).unwrap();
let metadata = file.metadata().unwrap();
@@ -138,6 +138,11 @@ fn pack(input: String, output: String) {
list_buffer.extend(element_buffer);
}
+ // Выравнивание буфера
+ while content_buffer.len() % 8 != 0 {
+ content_buffer.push(0);
+ }
+
let mut header_buffer: Vec<u8> = Vec::new();
// Пишем первый тип файла