Giter VIP home page Giter VIP logo

asar-rs's Introduction

asar

This crate allows for the parsing, reading, and writing of asar archives, often seen in Electron-based applications.

Examples

Listing the contents of an asar archive

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

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

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 or the Apache License 2.0, 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.

asar-rs's People

Contributors

absolucy avatar valentinegb avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.