1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
//! # tzip - TorrentZip Library for Rust
//!
//! Create, update, and validate TorrentZip-formatted ZIP files.
//!
//! ## What is TorrentZip?
//!
//! TorrentZip is a standardized ZIP format designed for reproducible, deterministic
//! archives. It ensures that identical input always produces byte-identical output,
//! making it ideal for:
//!
//! - ROM preservation and distribution
//! - BitTorrent sharing (identical hashes across sources)
//! - Content-addressable storage
//!
//! ## TorrentZip Requirements
//!
//! - All files sorted by lowercase filename
//! - Fixed timestamp: December 24, 1996, 23:32:00
//! - DEFLATE compression at maximum level (9)
//! - Archive comment: `TORRENTZIPPED-{CRC32}` where CRC32 is of the central directory
//!
//! ## Example: Creating a TorrentZip
//!
//! ```rust
//! use tzip::TorrentZipWriter;
//! use std::io::Cursor;
//!
//! let mut buffer = Cursor::new(Vec::new());
//! let mut tz = TorrentZipWriter::new(&mut buffer);
//!
//! tz.add_file("game.bin", &[0x00, 0x01, 0x02, 0x03]).unwrap();
//! tz.add_file("readme.txt", b"This is a readme").unwrap();
//!
//! tz.finish().unwrap();
//!
//! // buffer now contains a valid TorrentZip archive
//! println!("TorrentZip CRC32: {:08X}", tz.torrentzip_crc32().unwrap());
//! ```
pub use compute_central_directory_crc32;
pub use ;
pub use ;
pub use TorrentZipWriter;
/// Convenience function to create a TorrentZip from file pairs.
///
/// Files are automatically sorted by lowercase filename.
///
/// # Example
///
/// ```rust
/// use tzip::create_torrentzip;
/// use std::io::Cursor;
///
/// let files = vec![
/// ("file.txt".to_string(), b"Hello, World!".to_vec()),
/// ("data.bin".to_string(), vec![0x00, 0x01, 0x02]),
/// ];
///
/// let mut buffer = Cursor::new(Vec::new());
/// let crc32 = create_torrentzip(&mut buffer, files).unwrap();
/// println!("Created TorrentZip with CRC32: {:08X}", crc32);
/// ```