Crates.io | asar |
lib.rs | asar |
version | 0.3.0 |
source | src |
created_at | 2021-01-05 18:59:37.931883 |
updated_at | 2023-11-24 17:40:01.111893 |
description | A crate to read and write asar archives, often used by Electron apps. |
homepage | https://github.com/Absolucy/asar-rs |
repository | https://github.com/Absolucy/asar-rs |
max_upload_size | |
id | 332389 |
size | 100,572 |
This crate allows for the parsing, reading, and writing of asar archives, often seen in Electron-based applications.
use asar::{AsarReader, Header, Result};
use std::fs;
fn main() -> Result<()> {
let asar_file = fs::read("archive.asar")?;
let asar = AsarReader::new(&asar_file)?;
println!("There are {} files in archive.asar", asar.files().len());
for path in asar.files().keys() {
println!("{}", path.display());
}
Ok(())
}
use asar::{AsarReader, Header, Result};
use std::{fs, path::PathBuf};
fn main() -> Result<()> {
let asar_file = fs::read("archive.asar")?;
let asar = AsarReader::new(&asar_file)?;
let path = PathBuf::from("hello.txt");
let file = asar.files().get(&path).unwrap();
let contents = std::str::from_utf8(file.data()).unwrap();
assert_eq!(contents, "Hello, World!");
Ok(())
}
use asar::{AsarWriter, Result};
use std::fs::File;
fn main() -> Result<()> {
let mut asar = AsarWriter::new();
asar.write_file("hello.txt", b"Hello, World!", false)?;
asar.finalize(File::create("archive.asar")?)?;
Ok(())
}
integrity
: Enable integrity checks/calculation.check-integrity-on-read
: Enable integrity checks when reading an
archive, failing if any integrity check fails.write
- Enable writing an asar archive. Enabled by default, also
enables integrity
.asar
is licensed under either the MIT license or the
Apache License 2.0, at the choice of the user.
License: Apache-2.0 OR MIT
I, @Absolucy, fully give permission for any of my code (including the entirety of this project, asar-rs), anywhere, no matter the license, to be used to train machine learning models intended to be used for general-purpose programming or code analysis.