From 0413a96534020456e663f34b3577587f0d075191 Mon Sep 17 00:00:00 2001 From: Christian Uhsat Date: Sat, 8 Jun 2024 22:17:38 +0200 Subject: [PATCH] version v0.24.0 --- .github/workflows/go.yml | 2 +- internal/ffind/vsc.go | 27 --------------------------- internal/ffind/vsc_stub.go | 10 ---------- pkg/ffind/ffind.go | 35 ++++------------------------------- 4 files changed, 5 insertions(+), 69 deletions(-) delete mode 100644 internal/ffind/vsc.go delete mode 100644 internal/ffind/vsc_stub.go diff --git a/.github/workflows/go.yml b/.github/workflows/go.yml index ccb5cb5..09ee205 100644 --- a/.github/workflows/go.yml +++ b/.github/workflows/go.yml @@ -15,7 +15,7 @@ jobs: steps: - uses: actions/checkout@v3 - - name: Instal packages + - name: Install packages run: | sudo apt update -y sudo apt install -y qemu-utils diff --git a/internal/ffind/vsc.go b/internal/ffind/vsc.go deleted file mode 100644 index 3ae629c..0000000 --- a/internal/ffind/vsc.go +++ /dev/null @@ -1,27 +0,0 @@ -//go:build windows - -// Volume Shadow Copy functions (Windows only). -package ffind - -import ( - "os" - "path/filepath" - - "github.com/mxk/go-vss" -) - -const ( - symlink = "ffind" -) - -func ShadowCopy(drv string) (dir string, err error) { - dir = filepath.Join(os.TempDir(), symlink) - - if _, err = os.Stat(dir); !os.IsNotExist(err) { - os.Remove(dir) - } - - err = vss.CreateLink(dir, drv) - - return -} diff --git a/internal/ffind/vsc_stub.go b/internal/ffind/vsc_stub.go deleted file mode 100644 index b034a4f..0000000 --- a/internal/ffind/vsc_stub.go +++ /dev/null @@ -1,10 +0,0 @@ -//go:build !windows - -// Volume Shadow Copy functions (Error stub). -package ffind - -import "errors" - -func ShadowCopy(drive string) (dir string, err error) { - return "", errors.ErrUnsupported -} diff --git a/pkg/ffind/ffind.go b/pkg/ffind/ffind.go index 7e377d9..7ef1050 100644 --- a/pkg/ffind/ffind.go +++ b/pkg/ffind/ffind.go @@ -5,7 +5,6 @@ import ( "encoding/csv" "fmt" "os" - "path/filepath" "runtime" "sync" "time" @@ -13,7 +12,7 @@ import ( "github.com/cuhsat/fact/internal/fact" "github.com/cuhsat/fact/internal/fact/hash" "github.com/cuhsat/fact/internal/fact/zip" - vsc "github.com/cuhsat/fact/internal/ffind" + internal "github.com/cuhsat/fact/internal/ffind" "github.com/cuhsat/fact/internal/sys" "github.com/cuhsat/fact/pkg/windows" ) @@ -112,7 +111,7 @@ func (ff *ffind) enum(out chan<- string) { defer ff.wg.Done() if ff.sc { - sc, err := vsc.ShadowCopy(windows.SystemDrive()) + sc, err := internal.ShadowCopy(windows.SystemDrive()) if err != nil { sys.Fatal(err) @@ -179,14 +178,14 @@ func (ff *ffind) list(in <-chan string, out chan<- string) { w := csv.NewWriter(f) - err = w.Write(header()) + err = w.Write(internal.Header()) if err != nil { sys.Fatal(err) } for artifact := range in { - err = w.Write(record(artifact)) + err = w.Write(internal.Record(artifact)) if err != nil { sys.Error(err) @@ -241,29 +240,3 @@ func (ff *ffind) path(f string) string { return f[r:] } - -func header() []string { - return []string{ - "Filename", - "Path", - "Size (bytes)", - "Modified", - } -} - -func record(f string) (l []string) { - l = append(l, filepath.Base(f)) - l = append(l, f) - - fi, err := os.Stat(f) - - if err != nil { - sys.Error(err) - return - } - - l = append(l, fmt.Sprintf("%d", fi.Size())) - l = append(l, fi.ModTime().String()) - - return -}