https://github.com/src-d/go-siva
siva - seekable indexed verifiable archiver
https://github.com/src-d/go-siva
archive siva
Last synced: about 2 months ago
JSON representation
siva - seekable indexed verifiable archiver
- Host: GitHub
- URL: https://github.com/src-d/go-siva
- Owner: src-d
- License: mit
- Created: 2016-09-29T12:34:40.000Z (over 8 years ago)
- Default Branch: master
- Last Pushed: 2019-10-05T19:58:42.000Z (over 5 years ago)
- Last Synced: 2025-05-05T05:05:32.993Z (about 2 months ago)
- Topics: archive, siva
- Language: Go
- Homepage: https://godoc.org/gopkg.in/src-d/go-siva.v1
- Size: 99.6 KB
- Stars: 100
- Watchers: 7
- Forks: 19
- Open Issues: 3
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# siva format [](https://godoc.org/gopkg.in/src-d/go-siva.v1) [](https://travis-ci.org/src-d/go-siva) [](https://ci.appveyor.com/project/mcuadros/go-siva) [](https://codebeat.co/projects/github-com-src-d-go-siva)
_siva_ stand for seekable indexed verifiable archiver
_siva_ is archive format very similar to tar or zip, focused on allowing: constant-time random file access, seekable access to the contained files and concatenable archive files

The library implements a very similar API to the go [tar package](https://golang.org/pkg/archive/tar/), allowing full control over and low level access to the contained files.
- [Library reference](http://godoc.org/gopkg.in/src-d/go-siva.v1)
- [Command-line interface](#cli)
- [Format specification](https://github.com/src-d/go-siva/blob/master/SPEC.md)Installation
------------The recommended way to install siva
```
go get -u gopkg.in/src-d/go-siva.v1/...
```Example
-------Creating a siva file:
```go
// Create a buffer to write our archive to.
buf := new(bytes.Buffer)// Create a new siva archive.
w := siva.NewWriter(buf)// Add some files to the archive.
var files = []struct {
Name, Body string
}{
{"readme.txt", "This archive contains some text files."},
{"gopher.txt", "Gopher names:\nGeorge\nGeoffrey\nGonzo"},
{"todo.txt", "Get animal handling license."},
}
for _, file := range files {
hdr := &siva.Header{
Name: file.Name,
Mode: 0600,
ModTime: time.Now(),
}
if err := w.WriteHeader(hdr); err != nil {
log.Fatalln(err)
}
if _, err := w.Write([]byte(file.Body)); err != nil {
log.Fatalln(err)
}
}
// Make sure to check the error on Close.
if err := w.Close(); err != nil {
log.Fatalln(err)
}
```Reading from a siva file:
```go
// Open the siva archive for reading.
file := bytes.NewReader(buf.Bytes())
r := siva.NewReader(file)// Get all the files in the siva file.
i, err := r.Index()
if err != nil {
log.Fatalln(err)
}// Iterate through the files in the archive.
for _, e := range i {
content, err := r.Get(e)
if err != nil {
log.Fatalln(err)
}
fmt.Printf("Contents of %s:\n", e.Name)
if _, err := io.Copy(os.Stdout, content); err != nil {
log.Fatalln(err)
}
fmt.Println()
}
```Command-line interface
----------------------
siva cli interface, is a convenient command that helps you to creates and manipulates siva files.Output from: `./siva --help`:
```
Usage:
siva [OPTIONS]Help Options:
-h, --help Show this help messageAvailable commands:
list List the items contained on a file.
pack Create a new archive containing the specified items.
unpack Extract to disk from the archive.
version Show the version information.
```Other comments
------------------------ The `Index Signature` is specified as a sequence of 3 bytes. Go uses byte as an alias for uint8.
- `File Mode` in an `Index entry`, see [issue](https://github.com/src-d/go-siva/issues/11).
- This implementation left in the client of the library side the task of check the integrity of the file contents. It just checks for the `Index` integrity.License
-------MIT, see [LICENSE](LICENSE)