From 09b7bccc4cd1be5903e96bc3a22bc976fec8a420 Mon Sep 17 00:00:00 2001 From: Felicitas Pojtinger Date: Wed, 17 Nov 2021 21:38:01 +0100 Subject: [PATCH] feat: Start normalization of seeking behaviour in file and tape --- cmd/stfs-seek-file/main.go | 22 +++++++++++++++++----- 1 file changed, 17 insertions(+), 5 deletions(-) diff --git a/cmd/stfs-seek-file/main.go b/cmd/stfs-seek-file/main.go index 16e682a..ee3613f 100644 --- a/cmd/stfs-seek-file/main.go +++ b/cmd/stfs-seek-file/main.go @@ -3,6 +3,7 @@ package main import ( "archive/tar" "flag" + "io" "log" "os" ) @@ -33,10 +34,21 @@ func main() { tr := tar.NewReader(f) - hdr, err := tr.Next() - if err != nil { - panic(err) - } + for { + hdr, err := tr.Next() + if err != nil { + panic(err) + } - log.Println(hdr) + log.Println(hdr) + + curr, err := f.Seek(0, io.SeekCurrent) + if err != nil { + panic(err) + } + + if currentRecord := ((curr + hdr.Size) / blockSize) / int64(*recordSize); currentRecord > int64(*record) { + break + } + } }