applesauce_core/
lib.rs

1pub mod compressor;
2pub mod decmpfs;
3pub mod reader;
4pub mod writer;
5
6pub const BLOCK_SIZE: usize = 0x10000;
7
8/// Returns the number of blocks needed to store `size` bytes.
9#[must_use]
10#[inline]
11pub const fn num_blocks(size: u64) -> u64 {
12    size.div_ceil(BLOCK_SIZE as u64)
13}
14
15/// Rounds `size` up to the nearest multiple of `block_size`.
16///
17/// If `size` is already a multiple of `block_size`, it is returned unchanged.
18#[must_use]
19#[inline]
20pub const fn round_to_block_size(size: u64, block_size: u64) -> u64 {
21    match size % block_size {
22        0 => size,
23        r => size + (block_size - r),
24    }
25}