-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathfs.rs
More file actions
30 lines (22 loc) · 820 Bytes
/
fs.rs
File metadata and controls
30 lines (22 loc) · 820 Bytes
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
use archflow::{
compress::tokio::archive::ZipArchive, compress::FileOptions, compression::CompressionMethod,
error::ArchiveError,
};
use tokio::fs::File;
#[tokio::main]
async fn main() -> Result<(), ArchiveError> {
let file = File::create("archive.zip").await.unwrap();
let options = FileOptions::default().compression_method(CompressionMethod::Deflate());
let mut archive = ZipArchive::new_streamable(file);
archive
.append("file1.txt", &options, &mut b"hello\n".as_ref())
.await?;
let options = options
.compression_method(CompressionMethod::Store())
.last_modified_time(archflow::types::FileDateTime::UnixNow);
archive
.append("file2.txt", &options, &mut b"world\n".as_ref())
.await?;
archive.finalize().await?;
Ok(())
}