Skip to content

Commit

Permalink
version v0.24.1
Browse files Browse the repository at this point in the history
  • Loading branch information
cuhsat committed Jun 8, 2024
1 parent 0413a96 commit 48c41c2
Show file tree
Hide file tree
Showing 2 changed files with 108 additions and 0 deletions.
43 changes: 43 additions & 0 deletions internal/ffind/ffind.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
//go:build !windows

// FFind functions.
package ffind

import (
"errors"
"fmt"
"os"
"path/filepath"

"github.com/cuhsat/fact/internal/sys"
)

func ShadowCopy(drive string) (dir string, err error) {
return "", errors.ErrUnsupported
}

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
}
65 changes: 65 additions & 0 deletions internal/ffind/ffind_windows.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
//go:build windows

// FFind functions (Windows only).
package ffind

import (
"fmt"
"os"
"path/filepath"
"syscall"
"time"

"github.com/cuhsat/fact/internal/sys"
"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
}

func Header() []string {
return []string{
"Filename",
"Path",
"Size (bytes)",
"Modified",
"Accessed",
"Created",
}
}

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
}

fd := fi.Sys().(*syscall.Win32FileAttributeData)

m := time.Unix(0, fd.LastWriteTime.Nanoseconds())
a := time.Unix(0, fd.LastAccessTime.Nanoseconds())
c := time.Unix(0, fd.CreationTime.Nanoseconds())

l = append(l, fmt.Sprintf("%d", fi.Size()))
l = append(l, m.String(), a.String(), c.String())

return
}

0 comments on commit 48c41c2

Please sign in to comment.