mirror of
https://github.com/vbatts/go-mtree.git
synced 2024-11-22 00:15:39 +00:00
check: stubbing out the entry Type's
Signed-off-by: Vincent Batts <vbatts@hashbangbash.com>
This commit is contained in:
parent
a05d8ebbbd
commit
1cd7a57573
1 changed files with 43 additions and 0 deletions
43
check.go
43
check.go
|
@ -1,8 +1,51 @@
|
|||
package mtree
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"os"
|
||||
"path/filepath"
|
||||
"sort"
|
||||
)
|
||||
|
||||
type Result struct {
|
||||
}
|
||||
|
||||
var ErrNotAllClear = fmt.Errorf("some keyword check failed validation")
|
||||
|
||||
func Check(root string, dh *DirectoryHierarchy) (*Result, error) {
|
||||
creator := dhCreator{DH: dh}
|
||||
curDir, err := os.Getwd()
|
||||
if err == nil {
|
||||
defer os.Chdir(curDir)
|
||||
}
|
||||
|
||||
if err := os.Chdir(root); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
sort.Sort(byPos(creator.DH.Entries))
|
||||
|
||||
for _, e := range creator.DH.Entries {
|
||||
switch e.Type {
|
||||
case SpecialType:
|
||||
if e.Name == "/set" {
|
||||
creator.curSet = &e
|
||||
} else if e.Name == "/unset" {
|
||||
creator.curSet = nil
|
||||
}
|
||||
case DotDotType:
|
||||
// TODO step
|
||||
case RelativeType:
|
||||
// TODO determine path, and check keywords
|
||||
// or maybe to Chdir when type=dir?
|
||||
case FullType:
|
||||
info, err := os.Lstat(filepath.Join(root, e.Name))
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
// TODO check against keywords present
|
||||
_ = info
|
||||
}
|
||||
}
|
||||
|
||||
return nil, nil
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue