about summary refs log tree commit diff stats
path: root/internal/builder/files.go
diff options
context:
space:
mode:
Diffstat (limited to 'internal/builder/files.go')
-rw-r--r--internal/builder/files.go29
1 files changed, 29 insertions, 0 deletions
diff --git a/internal/builder/files.go b/internal/builder/files.go
index 57d4d2e..20fedf9 100644
--- a/internal/builder/files.go
+++ b/internal/builder/files.go
@@ -3,7 +3,9 @@ package builder
 import (
 	"compress/gzip"
 	"io"
+	"io/fs"
 	"os"
+	"path/filepath"
 
 	"github.com/andybalholm/brotli"
 )
@@ -81,3 +83,30 @@ func openFileAndVariants(filename string) (io.WriteCloser, error) {
 		return openFileWrite(filename)
 	}
 }
+
+func copyRecursive(src, dst string) error {
+	return filepath.WalkDir(src, func(path string, d fs.DirEntry, err error) error {
+		rel, err := filepath.Rel(src, path)
+		if err != nil {
+			return err
+		}
+		if d.IsDir() {
+			return mkdirp(dst, rel)
+		} else {
+			sf, err := os.Open(path)
+			if err != nil {
+				return err
+			}
+			defer sf.Close()
+			df, err := openFileAndVariants(filepath.Join(dst, rel))
+			if err != nil {
+				return err
+			}
+			defer df.Close()
+			if _, err := io.Copy(df, sf); err != nil {
+				return err
+			}
+		}
+		return nil
+	})
+}