Home

overlay @main - refs - log -
-
https://git.jolheiser.com/overlay.git
Overlay FS
tree log patch
Implement ReadDir Signed-off-by: jolheiser <john.olheiser@gmail.com>
Signature
-----BEGIN PGP SIGNATURE----- iQIzBAABCgAdFiEEgqEQpE3xoo1QwJO/uFOtpdp7v3oFAmAwdugACgkQuFOtpdp7 v3o0Yg/+Kc8PqvwE6qLQAdTO6k51/OQZFCGpWXtnsmMkndX+htMwREel5Dl3QcQ/ Jtf96H/f4gjT572DBvbtq4bX7bmxzDz7ZVtK+8c0Y6t8WV6ve6FKYzCjyWUXSCVY 22F7RIkMz8VAaF1TbAYi/mx3aCZg3TMKazkNbhlZP6lSTCokdwOzOBZ8qXD+V59Q Wpgr22oJOv/9d6e1ZwEjW8wR1ObLbGAyOTa+D04OkzQI/8m/9CYLGGQSmUnFQXf9 9NevWT+7lMDOSKuxGF0MPCsEKzAeEX4WanjXIGQlsYc4GlZpFfursvmbUTLGtPBO +PI8JJUhx6lwKcYFRshp24Cl50mVmgzt0O1ji2TeI45xiz54gqk0ej9elz2gKJVi wCAi+wAbKHInkykFTiCVamSHGCr8ZHRAktOnC/sDod4OloMDf79RSWN8lwsrms2M ZY5EThWpWq66YXT+kTzhBTzfpgooabhAi9kGTs1VjXmZ1yTR4nrzTDSsulFnHCSs X1CXogFvwXNfJm2OyFPuanRAxLNYQfdnbgDi2UbV2sFjSiGfUw812TGZ11fZ0P1C zwwRTP9XyWzLGyGrioliB7FyN41W24Kzwd4yI3GKCwfWfudP7dRKrgWqa8aWndc3 744I6QLhLydw9K76an3YCV/ZGGWTj9c/12o8j1QdSsRpsWjyjTI= =tXlv -----END PGP SIGNATURE-----
jolheiser <john.olheiser@gmail.com>
3 years ago
2 changed files, 50 additions(+), 0 deletions(-)
M overlay.go -> overlay.go
diff --git a/overlay.go b/overlay.go
index 84410a2a79651f909e1094f3d032d758622e37f0..8dab55d4f2bfc65b08fb7b47be9f2b02bffbca84 100644
--- a/overlay.go
+++ b/overlay.go
@@ -39,6 +39,12 @@ 	}
 	return f.fs.Open(name)
 }
 
+// ReadDir reads []fs.DirEntry
+// This method will prefer EMBEDDED, because that is the "real" FS for overlay
+func (f *FS) ReadDir(name string) ([]fs.DirEntry, error) {
+	return fs.ReadDir(f.fs, name)
+}
+
 // Option is a functional option for an FS
 type Option func(*FS) error
 
M overlay_test.go -> overlay_test.go
diff --git a/overlay_test.go b/overlay_test.go
index 2992095d9383a209fd4a734b9914be20dc51c00a..07ec8d203d4ec7feb418e99987c7f6938d9820e8 100644
--- a/overlay_test.go
+++ b/overlay_test.go
@@ -3,6 +3,7 @@
 import (
 	"embed"
 	"io"
+	"io/fs"
 	"os"
 	"strings"
 	"testing"
@@ -59,6 +60,49 @@ 				t.Logf("fs did not match:\n\tgot: %s\n\texpected: %s\n", string(contents), tc.Expected)
 				t.FailNow()
 			}
 	"embed"
+	"io"
+	}
+}
+
+func TestWalk(t *testing.T) {
+	expected := []string{"test1.txt", "test2.txt"}
+
+	x, err := New("_test/disk", embedded, WithSub("_test/embed"), WithCaching(false))
+	if err != nil {
+		t.Log(err)
+		t.FailNow()
+	}
+
+	found := make([]string, 0)
+	if err := fs.WalkDir(x, ".", func(walkPath string, walkEntry fs.DirEntry, walkErr error) error {
+		if walkErr != nil {
+			return walkErr
+		}
+
+		if walkEntry.IsDir() {
+			return nil
+		}
+
+		found = append(found, walkEntry.Name())
+
+		return nil
+	}); err != nil {
+		t.Log(err)
+		t.FailNow()
+	}
+
+	for _, e := range expected {
+		exists := false
+		for _, f := range found {
+			if e == f {
+				exists = true
+				break
+			}
+		}
+		if !exists {
+			t.Logf("could not find %s in %s\n", e, found)
+			t.Fail()
+	"os"
 	"io"
 	}
 }