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:
parent
119cdc314c
commit
faa80931af
11 changed files with 534 additions and 133 deletions
|
@ -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
|
||||
}
|
||||
)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue