Work in progress

This commit is contained in:
Alex Yatskov 2015-05-14 15:10:42 +09:00
parent 920dc8c841
commit bc51db532c
2 changed files with 18 additions and 2 deletions

View File

@ -31,6 +31,7 @@ import (
"path/filepath" "path/filepath"
"regexp" "regexp"
"strconv" "strconv"
"strings"
"time" "time"
) )
@ -53,7 +54,7 @@ type version struct {
} }
func newVersion(base string, parent *version) (*version, error) { func newVersion(base string, parent *version) (*version, error) {
re, err := regexp.Compile(`/vfs_([0-9a-f])$`) re, err := regexp.Compile(`^vfs_([0-9a-f])$`)
if err != nil { if err != nil {
return nil, err return nil, err
} }
@ -202,3 +203,18 @@ func (this *version) allocInode() uint64 {
func (this *version) Root() (fs.Node, error) { func (this *version) Root() (fs.Node, error) {
return this.root, nil return this.root, nil
} }
func (this *version) dump(root *versionedDir, depth int) {
indent := strings.Repeat("\t", depth)
for name, dir := range root.dirs {
fmt.Printf("%s%s (%s) >\n", indent, name, dir.node.path)
this.dump(dir, depth+1)
}
for name, file := range root.files {
fmt.Printf("%s%s (%s)\n", indent, name, file.node.path)
}
}
func (this *version) dumpRoot() {
this.dump(this.root, 0)
}

2
vfs.go
View File

@ -32,5 +32,5 @@ func main() {
log.Fatal(err) log.Fatal(err)
} }
db.save() db.lastVersion().dumpRoot()
} }