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
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
//! # PF6/PF8 Archive Library
//!
//! A Rust library for encoding and decoding PF6 and PF8 archive files.
//!
//! - **PF6**: Unencrypted format for simple file archiving
//! - **PF8**: Encrypted format with XOR encryption using SHA1-based keys
//!
//! ## Quick Start
//!
//! ### Reading PF6/PF8 Archives
//!
//! ```rust
//! use pf8::{Pf8Archive, Result, create_from_dir};
//! # use std::fs;
//! # use tempfile::TempDir;
//!
//! # fn main() -> Result<()> {
//! # let temp_dir = TempDir::new().unwrap();
//! # let archive_path = temp_dir.path().join("archive.pf8");
//! # let input_dir = temp_dir.path().join("input");
//! # fs::create_dir_all(&input_dir).unwrap();
//! # fs::write(input_dir.join("test.txt"), b"test content").unwrap();
//! # create_from_dir(&input_dir, &archive_path)?;
//! // Open an existing PF6/PF8 archive
//! let mut archive = Pf8Archive::open(&archive_path)?;
//!
//! // List all files in the archive
//! for entry in archive.entries() {
//! println!("{}: {} bytes", entry.path().display(), entry.size());
//! }
//!
//! // Extract all files to a directory
//! let output_dir = temp_dir.path().join("output");
//! archive.extract_all(&output_dir)?;
//!
//! // Extract a specific file
//! if let Some(_entry) = archive.get_entry("test.txt") {
//! let data = archive.read_file("test.txt")?;
//! let output_file = temp_dir.path().join("extracted_file.txt");
//! std::fs::write(output_file, data)?;
//! }
//! # Ok(())
//! # }
//! ```
//!
//! ### Creating PF8 Archives
//!
//! ```rust
//! use pf8::{Pf8Builder, Result};
//! # use std::fs;
//! # use tempfile::TempDir;
//!
//! # fn main() -> Result<()> {
//! # let temp_dir = TempDir::new().unwrap();
//! # let input_dir = temp_dir.path().join("input_directory");
//! # fs::create_dir_all(&input_dir).unwrap();
//! # fs::write(input_dir.join("test.txt"), b"test content").unwrap();
//! # let single_file = temp_dir.path().join("single_file.txt");
//! # fs::write(&single_file, b"single file content").unwrap();
//! # let output_path = temp_dir.path().join("output.pf8");
//! // Create a new archive builder
//! let mut builder = Pf8Builder::new();
//!
//! // Add files and directories
//! builder.add_dir(&input_dir)?;
//! builder.add_file(&single_file)?;
//! // builder.add_file_as("config.toml", "settings/config.toml")?;
//!
//! // Write the archive to a file
//! builder.write_to_file(&output_path)?;
//! # Ok(())
//! # }
//! ```
//!
//! ## Features
//!
//! - **Streaming Support**: Read and write archives without loading everything into memory
//! - **Dual Format Support**:
//! - PF6: Simple unencrypted format
//! - PF8: Encrypted format with XOR encryption and SHA1-based keys
//! - **Flexible API**: Both high-level convenience methods and low-level control
//! - **Path Handling**: Automatic conversion between system paths and internal format
//! - **Error Handling**: Comprehensive error types with detailed messages
// Re-export main types for convenience
pub use Pf8Archive;
pub use Pf8Builder;
pub use ;
pub use Pf8Entry;
pub use ;
pub use ArchiveFormat;
pub use Pf8Reader;
pub use Pf8Writer;
// Re-export convenience functions
pub use ;
// Re-export display functionality when feature is enabled
pub use list_archive;