Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/absolucy/asar-rs
Asar archive parsing in Rust
https://github.com/absolucy/asar-rs
Last synced: about 1 month ago
JSON representation
Asar archive parsing in Rust
- Host: GitHub
- URL: https://github.com/absolucy/asar-rs
- Owner: Absolucy
- License: other
- Created: 2022-06-17T21:35:48.000Z (over 2 years ago)
- Default Branch: main
- Last Pushed: 2023-11-24T17:38:38.000Z (about 1 year ago)
- Last Synced: 2024-11-14T21:29:53.406Z (about 2 months ago)
- Language: Rust
- Size: 87.9 KB
- Stars: 23
- Watchers: 1
- Forks: 5
- Open Issues: 2
-
Metadata Files:
- Readme: README.md
- License: LICENSE-Apache.md
Awesome Lists containing this project
README
# asar
This crate allows for the parsing, reading, and writing of [asar](https://github.com/electron/asar) archives,
often seen in [Electron](https://www.electronjs.org/)-based applications.## Examples
### Listing the contents of an asar archive
```rust
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(())
}
```### Reading a file from an asar archive
```rust
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(())
}
```### Writing a file to an asar archive
```rust
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(())
}
```## Features
- `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`.## License
`asar` is licensed under either the [MIT license](LICENSE-MIT) or the
[Apache License 2.0](LICENSE-APACHE), at the choice of the user.License: Apache-2.0 OR MIT
### Amendment
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.