diff options
Diffstat (limited to 'archive')
| -rw-r--r-- | archive/archive.go | 36 |
1 files changed, 14 insertions, 22 deletions
diff --git a/archive/archive.go b/archive/archive.go index 2fe039d..39ff9f8 100644 --- a/archive/archive.go +++ b/archive/archive.go @@ -4,15 +4,15 @@ import ( "archive/tar" "path/filepath" - "fmt" "io" "os" ) type Archive struct { - Output, Input string - file *os.File - writer *tar.Writer + Output string + Input []string + file *os.File + writer *tar.Writer } func (a *Archive) Tar() error { @@ -26,11 +26,12 @@ func (a *Archive) Tar() error { a.writer = tar.NewWriter(a.file) defer a.writer.Close() - if err := filepath.Walk(a.Input, a.tarWalkfn()); err != nil { - return err + for _, v := range a.Input { + if err := filepath.Walk(v, a.tarWalkfn()); err != nil { + return err + } } - fmt.Fprintln(os.Stderr, "done, remove me later") return nil } @@ -45,14 +46,15 @@ func (a *Archive) tarWalkfn() filepath.WalkFunc { if info.IsDir() { return nil } - // fmt.Fprintf(os.Stderr, "%s: Fileinfo: %s", path, info.IsDir()) f, err := os.Open(path) if err != nil { return err } - // defer f.Close() + defer f.Close() + // TODO; See if tar.FileInfoheader() could be used instead + // without the pathing issues I encountered h := &tar.Header{ Name: path, Size: info.Size(), @@ -60,26 +62,16 @@ func (a *Archive) tarWalkfn() filepath.WalkFunc { ModTime: info.ModTime(), } - // h, err := tar.FileInfoHeader(info, "") - if err != nil { - return err - } - err = a.writer.WriteHeader(h) if err != nil { - /* - fmt.Fprintf(os.Stderr, "This header has a problem: %s\n", h) - fmt.Fprintln(os.Stderr, "FUCK this error") - fmt.Fprintln(os.Stderr, err) - */ - // fmt.Fprintln(os.Stderr, "Here!") return err } _, err = io.Copy(a.writer, f) if err != nil { - fmt.Fprintln(os.Stderr, "here") - fmt.Fprintln(os.Stderr, f.Name()) + // TODO: Figure out how to add more useful information to + // These errors + // fmt.Fprintln(os.Stderr, f.Name()) return err } |
