47 lines
768 B
Go
47 lines
768 B
Go
package mfer
|
|
|
|
import (
|
|
"io"
|
|
"io/fs"
|
|
|
|
"github.com/spf13/afero"
|
|
)
|
|
|
|
type ManifestFile struct {
|
|
Path string
|
|
FileInfo fs.FileInfo
|
|
}
|
|
|
|
type Manifest struct {
|
|
SourceFS afero.Fs
|
|
Files []*ManifestFile
|
|
}
|
|
|
|
func NewFromPath(inputPath string) (*Manifest, error) {
|
|
afs := afero.NewBasePathFs(afero.NewOsFs(), inputPath)
|
|
return NewFromFilesystem(afs)
|
|
}
|
|
|
|
func NewFromFilesystem(fs afero.Fs) (*Manifest, error) {
|
|
m := &Manifest{
|
|
SourceFS: fs,
|
|
}
|
|
m.Scan()
|
|
return m, nil
|
|
}
|
|
|
|
func (m *Manifest) Scan() {
|
|
afero.Walk(m.SourceFS, "", func(path string, info fs.FileInfo, err error) error {
|
|
nf := &ManifestFile{
|
|
Path: path,
|
|
FileInfo: info,
|
|
}
|
|
m.Files = append(m.Files, nf)
|
|
return nil
|
|
})
|
|
}
|
|
|
|
func (m *Manifest) Write(output io.Writer) error {
|
|
return nil
|
|
}
|