Add support for creating a new directory

This commit is contained in:
Dane Everitt
2019-05-01 22:09:01 -07:00
parent c3515454f2
commit 857bf45324
2 changed files with 46 additions and 0 deletions

View File

@@ -9,6 +9,7 @@ import (
"io"
"io/ioutil"
"os"
"path"
"path/filepath"
"sort"
"strings"
@@ -261,6 +262,16 @@ func (fs *Filesystem) Stat(p string) (*Stat, error) {
return st, nil
}
// Creates a new directory (name) at a specificied path (p) for the server.
func (fs *Filesystem) CreateDirectory(name string, p string) error {
cleaned, err := fs.SafePath(path.Join(p, name))
if err != nil {
return err
}
return os.MkdirAll(cleaned, 0755)
}
// Lists the contents of a given directory and returns stat information about each
// file and folder within it.
func (fs *Filesystem) ListDirectory(p string) ([]*Stat, error) {