mirror of
https://github.com/redstrate/Physis.git
synced 2025-04-20 11:47:46 +00:00
Implement removing files in ZiPatch
This commit is contained in:
parent
528b7789b7
commit
6869e98f9d
1 changed files with 23 additions and 2 deletions
21
src/patch.rs
21
src/patch.rs
|
@ -701,6 +701,7 @@ pub fn create_patch(base_directory: &str, new_directory: &str) -> Option<ByteBuf
|
||||||
// A set of files not present in the new directory, that used to be in base (aka removedf iles)
|
// A set of files not present in the new directory, that used to be in base (aka removedf iles)
|
||||||
let removed_files: Vec<&PathBuf> = base_files.iter().filter(|item| !new_files.contains(item)).collect();
|
let removed_files: Vec<&PathBuf> = base_files.iter().filter(|item| !new_files.contains(item)).collect();
|
||||||
|
|
||||||
|
// Process added files
|
||||||
for file in added_files {
|
for file in added_files {
|
||||||
let file_data = read(file.to_str().unwrap()).unwrap();
|
let file_data = read(file.to_str().unwrap()).unwrap();
|
||||||
|
|
||||||
|
@ -731,6 +732,26 @@ pub fn create_patch(base_directory: &str, new_directory: &str) -> Option<ByteBuf
|
||||||
writer.seek(SeekFrom::Current(4));
|
writer.seek(SeekFrom::Current(4));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Process deleted files
|
||||||
|
for file in removed_files {
|
||||||
|
let remove_file_chunk = PatchChunk {
|
||||||
|
size: 0,
|
||||||
|
chunk_type: ChunkType::Sqpk(SqpkChunk {
|
||||||
|
size: 0,
|
||||||
|
operation: SqpkOperation::FileOperation(SqpkFileOperationData {
|
||||||
|
operation: SqpkFileOperation::DeleteFile,
|
||||||
|
offset: 0,
|
||||||
|
file_size: 0,
|
||||||
|
expansion_id: 0,
|
||||||
|
path: file.to_str().unwrap().parse().unwrap(),
|
||||||
|
}),
|
||||||
|
}),
|
||||||
|
crc32: 0,
|
||||||
|
};
|
||||||
|
|
||||||
|
remove_file_chunk.write(&mut writer).ok()?;
|
||||||
|
}
|
||||||
|
|
||||||
let eof_chunk = PatchChunk {
|
let eof_chunk = PatchChunk {
|
||||||
size: 0,
|
size: 0,
|
||||||
chunk_type: ChunkType::EndOfFile,
|
chunk_type: ChunkType::EndOfFile,
|
||||||
|
|
Loading…
Add table
Reference in a new issue