Documentation
¶
Overview ¶
Package fsp provides a interface for connect fsp server
package main
import (
"github.com/finove/fsp"
"fmt"
)
func main() {
var err error
var fspSession *fsp.Session
fspSession, err = fsp.NewSession("127.0.0.1:21", "123456")
if err != nil {
return
}
defer fspSession.Close()
fmt.Printf("fsp server version: %s\n", fspSession.Version())
}
Index ¶
- Constants
- type Error
- type File
- type Session
- func (s *Session) CanUpload(fileName string) (err error)
- func (s *Session) ChangePassword(newPassword string) (err error)
- func (s *Session) Close()
- func (s *Session) DownloadDirectory(remotePath, savePath string) (err error)
- func (s *Session) DwonloadFile(remotePath, savePath string, retry int) (err error)
- func (s *Session) GetProtecion(directory string) (protection uint8, err error)
- func (s *Session) Mkdir(directory string) (err error)
- func (s *Session) Readdir(dirpath string) (fi []os.FileInfo, err error)
- func (s *Session) Remove(name string) (err error)
- func (s *Session) RemoveAll(path string) (err error)
- func (s *Session) Rename(oldpath, newpath string) (err error)
- func (s *Session) ShowDir(dirpath string) (err error)
- func (s *Session) Stat(name string) (info os.FileInfo, err error)
- func (s *Session) UploadFile(localFile, remotePath string) (err error)
- func (s *Session) Version() (version string)
Constants ¶
View Source
const ( FSPCommandVersion = 0x10 /* return server's version string. */ FSPCommandInfo = 0x11 /* return server's extended info block */ FSPCommandErr = 0x40 /* error response from server. */ FSPCommandGetDir = 0x41 /* get a directory listing. */ FSPCommandGetFile = 0x42 /* get a file. */ FSPCommandUpload = 0x43 /* open a file for writing. */ FSPCommandInstall = 0x44 /* close a file opened for writing. */ FSPCommandDelFile = 0x45 /* delete a file. */ FSPCommandDelDir = 0x46 /* delete a directory. */ FSPCommandGetPro = 0x47 /* get directory protection. */ FSPCommandSetPro = 0x48 /* set directory protection. */ FSPCommandMakeDir = 0x49 /* create a directory. */ FSPCommandBye = 0x4A /* finish a session. */ FSPCommandGrabFile = 0x4B /* atomic get+delete a file. */ FSPCommandGrabDone = 0x4C /* atomic get+delete a file done. */ FSPCommandStat = 0x4D /* get information about file. */ FSPCommandRename = 0x4E /* rename file or directory. */ FSPCommandChangePass = 0x4F /* change password */ FSPCommandLimit = 0x80 /* # > 0x7f for future cntrl blk ext. */ FSPCommandTest = 0x81 /* reserved for testing */ )
definition of FSP protocol v2 commands
View Source
const ( FSPHSzie = 12 FSPSpace = 14708 FSPMaxPacket = FSPHSzie + FSPSpace )
FSP packet
View Source
const ( FSPProBytes = 1 FSPDirOwner = 0x01 // caller owns the directory FSPDirDel = 0x02 // files can be deleted from this dir FSPDirAdd = 0x04 // files can be added to this dir FSPDirMkDir = 0x08 // new subdirectories can be created FSPDirGet = 0x10 // files are NOT readable by non-owners FSPDirReadme = 0x20 // directory contain an readme file FSPDirList = 0x40 // directory can be listed FSPDirRename = 0x80 // files can be renamed in this directory )
directory protection bits
View Source
const (
// VERSION represent fsp lib version.
VERSION = "1.0.1"
)
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type File ¶
type File struct {
// contains filtered or unexported fields
}
File fsp file handle
type Session ¶
type Session struct {
// contains filtered or unexported fields
}
Session fsp session
func NewSession ¶
NewSession return a new Session
func NewSessionWithConn ¶
func NewSessionWithConn(conn *net.UDPConn, serverAddress, password string) (session *Session, err error)
NewSessionWithConn return a new Session
func (*Session) ChangePassword ¶
ChangePassword change password of fsp server
func (*Session) DownloadDirectory ¶
DownloadDirectory download dir from fsp server
func (*Session) DwonloadFile ¶
DwonloadFile download file from fsp server
func (*Session) GetProtecion ¶
GetProtecion get protection byte from directory
func (*Session) UploadFile ¶
UploadFile upload file to fsp server
Click to show internal directories.
Click to hide internal directories.