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.
star/sftp/sftp.go

27 lines
535 B
Go

package sftp
import (
"b612.me/starssh"
"os"
"path"
"path/filepath"
)
func TransferFile(s *starssh.StarSSH, local, remote string, isPull, fullname bool) error {
if !fullname && !isPull {
s.ShellOne("mkdir -p " + remote)
remote = remote + "/" + filepath.Base(local)
}
if !fullname && isPull {
os.MkdirAll(local, 0755)
local = filepath.Join(local, path.Base(remote))
}
if fullname && isPull {
os.MkdirAll(filepath.Dir(local), 0755)
}
if fullname && !isPull {
os.MkdirAll(path.Dir(remote), 0755)
}
return nil
}