aboutsummaryrefslogtreecommitdiff
path: root/storage/storage_fs.go
diff options
context:
space:
mode:
Diffstat (limited to 'storage/storage_fs.go')
-rw-r--r--storage/storage_fs.go40
1 files changed, 40 insertions, 0 deletions
diff --git a/storage/storage_fs.go b/storage/storage_fs.go
new file mode 100644
index 0000000..35ce58b
--- /dev/null
+++ b/storage/storage_fs.go
@@ -0,0 +1,40 @@
+package storage
+
+import (
+ "os"
+ "path/filepath"
+)
+
+type FileSystem struct {
+ root string
+}
+
+func WalkFolder(folder string, walkMode WalkMode) <-chan string {
+ c := make(chan string)
+
+ go func(folder string, c chan string) {
+ filepath.Walk(folder, func(path string, info os.FileInfo, err error) error {
+ file, _ := os.Open(path)
+ defer file.Close()
+ fileInfo, _ := file.Stat()
+
+ switch walkMode {
+ case Folder:
+ if fileInfo.IsDir() {
+ c <- path
+ }
+ case File:
+ if !fileInfo.IsDir() {
+ c <- path
+ }
+ case FileFolder:
+ c <- path
+ }
+ return nil
+ })
+ close(c)
+
+ }(folder, c)
+
+ return c
+}