1
0
Fork 0
mirror of https://github.com/vbatts/go-mtree.git synced 2025-07-07 16:18:28 +00:00

*: refactoring to support streams

when creating a manifest from, or validating, a stream like a tar
archive, it requires thinking about some of the functions differently
than walking a directory tree.

This is the beginning of allowing for such features.

Signed-off-by: Vincent Batts <vbatts@hashbangbash.com>
This commit is contained in:
Vincent Batts 2016-04-15 18:39:18 -04:00 committed by Stephen Chung
parent 119cdc314c
commit faa80931af
11 changed files with 534 additions and 133 deletions

View file

@ -2,22 +2,36 @@
package mtree
import "os"
import (
"archive/tar"
"fmt"
"io"
"os"
)
var (
unameKeywordFunc = func(path string, info os.FileInfo) (string, error) {
unameKeywordFunc = func(path string, info os.FileInfo, r io.Reader) (string, error) {
if hdr, ok := info.Sys().(*tar.Header); ok {
return fmt.Sprintf("uname=%s", hdr.Uname), nil
}
return "", nil
}
uidKeywordFunc = func(path string, info os.FileInfo) (string, error) {
uidKeywordFunc = func(path string, info os.FileInfo, r io.Reader) (string, error) {
if hdr, ok := info.Sys().(*tar.Header); ok {
return fmt.Sprintf("uid=%d", hdr.Uid), nil
}
return "", nil
}
gidKeywordFunc = func(path string, info os.FileInfo) (string, error) {
gidKeywordFunc = func(path string, info os.FileInfo, r io.Reader) (string, error) {
if hdr, ok := info.Sys().(*tar.Header); ok {
return fmt.Sprintf("gid=%d", hdr.Gid), nil
}
return "", nil
}
nlinkKeywordFunc = func(path string, info os.FileInfo) (string, error) {
nlinkKeywordFunc = func(path string, info os.FileInfo, r io.Reader) (string, error) {
return "", nil
}
xattrKeywordFunc = func(path string, info os.FileInfo) (string, error) {
xattrKeywordFunc = func(path string, info os.FileInfo, r io.Reader) (string, error) {
return "", nil
}
)