feat: add media store and store medias
This commit is contained in:
29
backend/pkg/path/fs.go
Normal file
29
backend/pkg/path/fs.go
Normal file
@@ -0,0 +1,29 @@
|
||||
package path
|
||||
|
||||
import (
|
||||
"os"
|
||||
|
||||
"github.com/pkg/errors"
|
||||
)
|
||||
|
||||
func GetSubDirs(root string) ([]string, error) {
|
||||
fd, err := os.Open(root)
|
||||
if err != nil {
|
||||
return nil, errors.Wrapf(err, "open root directory: %s", root)
|
||||
}
|
||||
defer fd.Close()
|
||||
|
||||
entries, err := fd.Readdir(-1)
|
||||
if err != nil {
|
||||
return nil, errors.Wrapf(err, "read root directory: %s", root)
|
||||
}
|
||||
|
||||
var paths []string
|
||||
for _, entry := range entries {
|
||||
if entry.IsDir() {
|
||||
paths = append(paths, entry.Name())
|
||||
}
|
||||
}
|
||||
|
||||
return paths, nil
|
||||
}
|
||||
Reference in New Issue
Block a user