sos_archive/
lib.rs

1#![deny(missing_docs)]
2#![forbid(unsafe_code)]
3//! ZIP archive reader and writer for account backup archives.
4
5mod error;
6mod reader;
7mod writer;
8
9pub use error::Error;
10pub use reader::Reader as ZipReader;
11pub use writer::Writer as ZipWriter;
12
13/// Manifest file for archives.
14pub const ARCHIVE_MANIFEST: &str = "sos-manifest.json";
15
16pub(crate) type Result<T> = std::result::Result<T, Error>;
17
18/// Returns a relative path without reserved names,
19/// redundant separators, ".", or "..".
20pub fn sanitize_file_path(path: &str) -> std::path::PathBuf {
21    // Replaces backwards slashes
22    path.replace('\\', "/")
23        // Sanitizes each component
24        .split('/')
25        .map(sanitize_filename::sanitize)
26        .collect()
27}