-
Notifications
You must be signed in to change notification settings - Fork 12
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
925f952
commit b4d3577
Showing
17 changed files
with
131 additions
and
261 deletions.
There are no files selected for viewing
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,10 +1,10 @@ | ||
language: go | ||
|
||
go: | ||
- 1.4.3 | ||
- 1.5.4 | ||
- 1.6.4 | ||
- 1.7.6 | ||
- 1.8.3 | ||
|
||
script: make check | ||
- 1.17 | ||
- 1.16 | ||
- 1.15 | ||
- 1.14 | ||
- 1.13 | ||
- 1.12 | ||
- 1.11 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,62 +1,9 @@ | ||
# go-cpio [![GoDoc](https://godoc.org/github.com/cavaliercoder/go-cpio?status.svg)](https://godoc.org/github.com/cavaliercoder/go-cpio) [![Build Status](https://travis-ci.org/cavaliercoder/go-cpio.svg?branch=master)](https://travis-ci.org/cavaliercoder/go-cpio) [![Go Report Card](https://goreportcard.com/badge/github.com/cavaliercoder/go-cpio)](https://goreportcard.com/report/github.com/cavaliercoder/go-cpio) | ||
# cpio | ||
[![Go Reference](https://pkg.go.dev/badge/github.com/cavaliergopher/cpio.svg)](https://pkg.go.dev/github.com/cavaliergopher/cpio) [![Build Status](https://app.travis-ci.com/cavaliergopher/cpio.svg?branch=main)](https://app.travis-ci.com/cavaliergopher/cpio) [![Go Report Card](https://goreportcard.com/badge/github.com/cavaliergopher/cpio)](https://goreportcard.com/report/github.com/cavaliergopher/cpio) | ||
|
||
This package provides a Go native implementation of the CPIO archive file | ||
format. | ||
Package cpio provides readers and writers for the CPIO archive file format. | ||
|
||
Currently, only the SVR4 (New ASCII) format is supported, both with and without | ||
checksums. | ||
|
||
```go | ||
// Create a buffer to write our archive to. | ||
buf := new(bytes.Buffer) | ||
|
||
// Create a new cpio archive. | ||
w := cpio.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 := &cpio.Header{ | ||
Name: file.Name, | ||
Mode: 0600, | ||
Size: int64(len(file.Body)), | ||
} | ||
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) | ||
} | ||
|
||
// Open the cpio archive for reading. | ||
b := bytes.NewReader(buf.Bytes()) | ||
r := cpio.NewReader(b) | ||
|
||
// Iterate through the files in the archive. | ||
for { | ||
hdr, err := r.Next() | ||
if err == io.EOF { | ||
// end of cpio archive | ||
break | ||
} | ||
if err != nil { | ||
log.Fatalln(err) | ||
} | ||
fmt.Printf("Contents of %s:\n", hdr.Name) | ||
if _, err := io.Copy(os.Stdout, r); err != nil { | ||
log.Fatalln(err) | ||
} | ||
fmt.Println() | ||
} | ||
``` | ||
Copyright 2021, Ryan Armstrong <[email protected]> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
/* | ||
Package cpio providers readers and writers for CPIO archives. Currently, only | ||
the SVR4 (New ASCII) format is supported, both with and without checksums. | ||
This package aims to be feel like Go's archive/tar package. | ||
See the [CPIO man page](https://www.freebsd.org/cgi/man.cgi?query=cpio&sektion=5). | ||
*/ | ||
package cpio |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
module github.com/cavaliergopher/cpio | ||
|
||
go 1.17 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.