You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
35 lines
614 B
Go
35 lines
614 B
Go
package commands
|
|
|
|
import (
|
|
"strings"
|
|
|
|
"git.snorba.art/hugo/nssh/storage"
|
|
)
|
|
|
|
type MkdirCommand struct {
|
|
filestore storage.Filestore
|
|
}
|
|
|
|
func (c *MkdirCommand) Execute(arguments []string) error {
|
|
for _, dir := range arguments {
|
|
if len(dir) > 0 && dir[0] != '-' {
|
|
var currentPath string
|
|
for _, part := range strings.Split(dir, "/") {
|
|
if part == "" {
|
|
continue
|
|
}
|
|
|
|
currentPath += "/" + part
|
|
if exists, _ := c.filestore.DirectoryExists(currentPath); !exists {
|
|
err := c.filestore.MakeDirectory(currentPath)
|
|
if err != nil {
|
|
return err
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
return nil
|
|
}
|