Skip to content

Commit 6098bf6

Browse files
committed
diff/patch features in readme, c4 fixes
1 parent 48e30a6 commit 6098bf6

File tree

2 files changed

+39
-11
lines changed

2 files changed

+39
-11
lines changed

Readme.md

Lines changed: 29 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,14 +4,38 @@ Work in progress.
44

55
## Features
66

7-
- Walk
8-
+ Walk walks a absfs.FileSystem similar to the filepath Walk standard library function.
7+
- Walk
8+
+ Walk walks a absfs.FileSystem similar to the filepath Walk standard
9+
library function.
910

1011
- WalkWithOptions
11-
+ Adds the ability to specify options for how a walk is performed. Such as if directories are sorted and in what order, normal or fast walk, traversal order, symbolic link handling and more.
12+
+ Adds the ability to specify options for how a walk is performed. Such as
13+
if directories are sorted and in what order, normal or fast walk,
14+
traversal order, symbolic link handling and more.
1215

13-
- Copy
14-
+ Copy copies filesystem structures form one filesystem to another with a options to filter what is copied, and transform the data during the copy process.
16+
- PreOrder, PostOrder, InOrder and BreadthFirst Walkers
17+
+ Additional walking strategies for ordered traversal of file systems.
1518

19+
- Copy
20+
+ Copy copies filesystem structures form one filesystem to another with
21+
options for selecting and transforming what is copied.
22+
23+
- Describe
24+
+ Creates a data structure that describes a file system. The description
25+
contains basic metadata as found in `os.FileInfo`, the identification
26+
of file data and directories using a (c4 Id)[https://github.com/Avalanche-io/c4],
27+
and can be serialized into JSON, YAML, CUE and other formats.
28+
29+
- Diff
30+
+ Returns the difference between two file system descriptions.
31+
32+
- Patch
33+
+ Given a file system that matches the first file system in a Diff, and a
34+
c4 data source Patch will transform the file system to match the second
35+
file system in a diff. Requires a c4 data source.
36+
37+
- Apply
38+
+ Apply takes a file system, c4 data source, and file system description and
39+
transforms the file system to match the description.
1640

1741

time_test.go

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ import (
2222
)
2323

2424
type fileinfo struct {
25-
Digest c4.Digest // 64
25+
Id c4.ID // 64
2626
Size int64 // 8
2727
TotalSize int64 // 8
2828
Mode os.FileMode // 4
@@ -34,7 +34,7 @@ type fileinfo struct {
3434

3535
func (i *fileinfo) MarshalBinary() (data []byte, err error) {
3636
data = make([]byte, 118+len(i.Name))
37-
copy(data[0:64], i.Digest)
37+
copy(data[0:64], i.Id[:])
3838
binary.LittleEndian.PutUint64(data[64:72], uint64(i.Size))
3939
binary.LittleEndian.PutUint64(data[72:80], uint64(i.TotalSize))
4040
binary.LittleEndian.PutUint32(data[80:84], uint32(i.Mode))
@@ -56,7 +56,7 @@ func (i *fileinfo) MarshalBinary() (data []byte, err error) {
5656
}
5757

5858
func (i *fileinfo) UnmarshalBinary(data []byte) error {
59-
copy(i.Digest, data[0:64])
59+
copy(i.Id[:], data[0:64])
6060
i.Size = int64(binary.LittleEndian.Uint64(data[64:72]))
6161
i.TotalSize = int64(binary.LittleEndian.Uint64(data[72:80]))
6262
i.Mode = os.FileMode(binary.LittleEndian.Uint32(data[80:84]))
@@ -68,7 +68,10 @@ func (i *fileinfo) UnmarshalBinary(data []byte) error {
6868
}
6969

7070
func TestTime(t *testing.T) {
71-
var fs, localfs absfs.FileSystem
71+
72+
t.Skip("skipping test, not fully implemented")
73+
74+
var fs, localfs absfs.SymlinkFileSystem // FileSystem
7275
var err error
7376
localfs, err = osfs.NewFS()
7477
if err != nil {
@@ -111,9 +114,10 @@ func TestTime(t *testing.T) {
111114
if err != nil {
112115
t.Fatal(err)
113116
}
114-
fmt.Printf("local walk: %s\n", time.Now().Sub(start_time))
117+
118+
// fmt.Printf("local walk: %s\n", time.Now().Sub(start_time))
115119
start_time = time.Now()
116-
fmt.Printf("cnt: %d\n", cnt)
120+
// fmt.Printf("cnt: %d\n", cnt)
117121
err = fstools.PostOrder(fs, nil, "/", func(path string, info os.FileInfo, err error) error {
118122
metadata, err := LoadMetadata(fs, path)
119123
if err != nil {

0 commit comments

Comments
 (0)