29 lines
643 B
Go
Executable File
29 lines
643 B
Go
Executable File
package notes
|
|
|
|
import (
|
|
"errors"
|
|
"io/ioutil"
|
|
"gogs.inhome.blapointe.com/local/notes-server/filetree"
|
|
)
|
|
|
|
func (n *Notes) Dir(urlPath string) (string, string, error) {
|
|
p := filetree.NewPathFromURL(urlPath)
|
|
if !p.IsDir() {
|
|
return "", "", errors.New("not a dir")
|
|
}
|
|
dirs, files := n.lsDir(p)
|
|
return dirs.List(), files.List(), nil
|
|
}
|
|
|
|
func (n *Notes) lsDir(path filetree.Path) (filetree.Paths, filetree.Paths) {
|
|
dirs := filetree.NewDirs()
|
|
files := filetree.NewFiles()
|
|
|
|
found, _ := ioutil.ReadDir(path.Local)
|
|
for _, f := range found {
|
|
dirs.Push(path, f)
|
|
files.Push(path, f)
|
|
}
|
|
return filetree.Paths(*dirs), filetree.Paths(*files)
|
|
}
|