notes-server/server/dir.go

32 lines
505 B
Go

package server
import (
"io/ioutil"
"log"
"net/http"
"os"
)
func isDir(path string) bool {
stat, err := os.Stat(path)
return err == nil && stat.IsDir()
}
func notesDir(path string, w http.ResponseWriter, r *http.Request) {
dirs, files := lsDir(path)
log.Println(dirs)
log.Println(files)
}
func lsDir(p string) ([]Path, []Path) {
dirs := newDirs()
files := newFiles()
found, _ := ioutil.ReadDir(p)
for _, f := range found {
dirs.Push(p, f)
files.Push(p, f)
}
return *dirs, *files
}