new commends

closes #4
closes #14
closes #3

Signed-off-by: Vasiliy Tolstov <v.tolstov@selfip.ru>
This commit is contained in:
Василий Толстов 2015-05-06 16:15:39 +03:00
parent f608085a3e
commit d8b8730f40
2 changed files with 37 additions and 8 deletions

37
main.go
View File

@ -544,14 +544,22 @@ func (s *Conn) cmdServerMkd(args string) {
}
if p != "" && p != "." {
path := ""
for _, part := range strings.Split(filepath.Clean(p), "/") {
path = filepath.Join(path, part)
var f *swift.ObjectCreateFile
f, err = s.sw.ObjectCreate(cnt, p, false, "", "application/directory", nil)
f, err = s.sw.ObjectCreate(cnt, path, false, "", "application/directory", nil)
if err != nil {
fmt.Printf(err.Error())
s.ctrl.PrintfLine(`550 Create failed "%s"`, args)
return
}
err = f.Close()
}
if err != nil {
s.ctrl.PrintfLine(`550 Create failed "%s"`, args)
return
}
} else {
err = s.sw.ContainerCreate(cnt, nil)
}
@ -639,13 +647,32 @@ func (s *Conn) cmdServerSite(args string) {
}
func (s *Conn) cmdServerRnfr(args string) {
// s.Src = args
s.ctrl.PrintfLine(`550 Success`)
if args[0] == '/' {
s.movesrc = args
} else {
s.movesrc = filepath.Clean(filepath.Join(s.path, args))
}
s.ctrl.PrintfLine(`200 Success`)
}
func (s *Conn) cmdServerRnto(args string) {
// s.Dst = args
s.ctrl.PrintfLine(`550 Success`)
var err error
if args[0] == '/' {
s.movedst = args
} else {
s.movedst = filepath.Clean(filepath.Join(s.path, args))
}
cntsrc := strings.Split(s.movesrc, "/")[1]
psrc := strings.Join(strings.Split(s.movesrc, "/")[2:], "/")
cntdst := strings.Split(s.movedst, "/")[1]
pdst := strings.Join(strings.Split(s.movedst, "/")[2:], "/")
if err = s.sw.ObjectMove(cntsrc, psrc, cntdst, pdst); err != nil {
s.ctrl.PrintfLine("552 Failed to store file")
return
}
s.movesrc = ""
s.movedst = ""
s.ctrl.PrintfLine(`200 Success`)
}
func (s *Conn) cmdServerAuth(args string) {

View File

@ -20,6 +20,8 @@ type Conn struct {
path string
api string
passive bool
movesrc string
movedst string
}
func (c *Conn) Close() error {