[](https://github.com/lostatc/sqlarfs-rs/actions/workflows/test.yaml)
[](https://app.codecov.io/gh/lostatc/sqlarfs-rs)
[](https://crates.io/crates/sqlarfs)
[](https://docs.rs/sqlarfs)
# sqlarfs
A file archive format and virtual filesystem backed by a SQLite database.
This library is a Rust implementation of the
[sqlar](https://sqlite.org/sqlar.html) format for SQLite archive files.
This library consists of:
- A Rust API
- A CLI
- TODO: A FUSE filesystem
## Rust API
To add this library to your project:
```shell
cargo add sqlarfs
```
See the [API docs](https://docs.rs/sqlarfs) for documentation and examples.
## CLI
### Installation
To install the CLI tool, [install
Rust](https://www.rust-lang.org/tools/install) and run:
```shell
cargo install sqlarfs-cli
```
The binary will be installed to `~/.cargo/bin/sqlar`.
### Examples
Archive directory and extract it to a target directory:
```shell
sqlar create ./src
sqlar extract -a src.sqlar ~/Desktop
```
Archive two directories and extract them to the current directory:
```shell
sqlar create -a files.sqlar ~/Documents ~/Pictures
sqlar extract -a files.sqlar
```
Extract a specific file from an archive:
```shell
sqlar extract -a documents.sqlar -s Documents/report.pdf
```
Add a file to an existing archive.
```shell
sqlar archive -a documents.sqlar ~/Downloads/report.pdf Documents/report.pdf
```
List all regular files in an archive:
```shell
sqlar list -a documents.sqlar -t file
```
List only the immediate children of a specific directory in an archive:
```shell
sqlar list -a documents.sqlar --children Documents/Reports/
```
Remove a file from an archive:
```shell
sqlar remove -a documents.sqlar Documents/report.pdf
```
The tool has a shorthand syntax for each command:
```shell
sqlar c -a files.sqlar ~/Documents ~/Pictures
sqlar ex -a files.sqlar
sqlar ls -a files.sqlar
sqlar rm -a files.sqlar Documents
```