commit 70b9150cff0f74fc85310b5a47643aab455ba579 Author: Vincent Batts Date: Tue Feb 3 23:29:41 2015 +0100 init diff --git a/main.go b/main.go new file mode 100644 index 0000000..70fb81a --- /dev/null +++ b/main.go @@ -0,0 +1,64 @@ +package main + +import ( + "crypto" + "flag" + "io" + "log" + "os" +) + +func main() { + flag.Parse() + + hdrBuff := make([]byte, BlockSize) + + for _, arg := range flag.Args() { + func() { + // Open the tar archive + fh, err := os.Open(arg) + if err != nil { + log.Fatal(err) + } + defer fh.Close() + + // prep our buffer + buf := hdrBuff[:] + copy(buf, zeroBlock) + + if _, err := io.ReadFull(fh, buf); err != nil { + log.Fatal(err) + } + }() + } +} + +const BlockSize = 512 + +var ( + zeroBlock = make([]byte, BlockSize) + + flOutputJson = flag.String("o", "", "output json of the tar archives") +) + +type ( + // for a whole tar archive + TarInfo struct { + Name string + Entries []Entry + + // TODO(vbatts) would be nice to satisfy the Reader interface, so that this could be passed directly to tar.Reader + } + + // each file from the tar archive has it's header copied exactly, + //and payload of it's file Checksummed if the file size is greater than 0 + Entry struct { + Pos int64 + Header []byte + Size int64 + Checksum []byte + Hash crypto.Hash + + // TODO(vbatts) perhaps have info to find the file on disk, to provide an io.Reader + } +)