aboutsummaryrefslogtreecommitdiff
path: root/weed/shell/command_fs_mkdir.go
diff options
context:
space:
mode:
authorBl1tz23 <alex3angle@gmail.com>2021-08-10 13:45:24 +0300
committerBl1tz23 <alex3angle@gmail.com>2021-08-10 13:45:24 +0300
commit1c94b3d01340baad000188550fcf2ccab6ca80e5 (patch)
tree12c3da17eb2d1a43fef78021a3d7c79110b0ff5f /weed/shell/command_fs_mkdir.go
parente6e57db530217ff57b3622b4672b03ebb6313e96 (diff)
parentf9cf9b93d32a2b01bc4d95ce7d24d86ef60be668 (diff)
downloadseaweedfs-1c94b3d01340baad000188550fcf2ccab6ca80e5.tar.xz
seaweedfs-1c94b3d01340baad000188550fcf2ccab6ca80e5.zip
merge master, resolve conflicts
Diffstat (limited to 'weed/shell/command_fs_mkdir.go')
-rw-r--r--weed/shell/command_fs_mkdir.go57
1 files changed, 57 insertions, 0 deletions
diff --git a/weed/shell/command_fs_mkdir.go b/weed/shell/command_fs_mkdir.go
new file mode 100644
index 000000000..11b663eec
--- /dev/null
+++ b/weed/shell/command_fs_mkdir.go
@@ -0,0 +1,57 @@
+package shell
+
+import (
+ "context"
+ "github.com/chrislusf/seaweedfs/weed/pb/filer_pb"
+ "github.com/chrislusf/seaweedfs/weed/util"
+ "io"
+ "os"
+ "time"
+)
+
+func init() {
+ Commands = append(Commands, &commandFsMkdir{})
+}
+
+type commandFsMkdir struct {
+}
+
+func (c *commandFsMkdir) Name() string {
+ return "fs.mkdir"
+}
+
+func (c *commandFsMkdir) Help() string {
+ return `create a directory
+
+ fs.mkdir path/to/dir
+`
+}
+
+func (c *commandFsMkdir) Do(args []string, commandEnv *CommandEnv, writer io.Writer) (err error) {
+
+ path, err := commandEnv.parseUrl(findInputDirectory(args))
+ if err != nil {
+ return err
+ }
+
+ dir, name := util.FullPath(path).DirAndName()
+
+ err = commandEnv.WithFilerClient(func(client filer_pb.SeaweedFilerClient) error {
+
+ _, createErr := client.CreateEntry(context.Background(), &filer_pb.CreateEntryRequest{
+ Directory: dir,
+ Entry: &filer_pb.Entry{
+ Name: name,
+ IsDirectory: true,
+ Attributes: &filer_pb.FuseAttributes{
+ Mtime: time.Now().Unix(),
+ Crtime: time.Now().Unix(),
+ FileMode: uint32(0777 | os.ModeDir),
+ },
+ },
+ })
+ return createErr
+ })
+
+ return
+}