builds now
This commit is contained in:
46
mfer/manifest.go
Normal file
46
mfer/manifest.go
Normal file
@@ -0,0 +1,46 @@
|
||||
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
|
||||
}
|
||||
Reference in New Issue
Block a user