transfer

package
v0.0.0-...-e89c6da Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Aug 1, 2014 License: MIT Imports: 10 Imported by: 0

Documentation

Index

Constants

View Source
const (
	BLOCK_SIZE = 512 * 1024
)

Variables

This section is empty.

Functions

This section is empty.

Types

type Client

type Client struct {
	Addr string
	// contains filtered or unexported fields
}

func NewClient

func NewClient(addr string) *Client

func (*Client) Close

func (c *Client) Close() error

func (*Client) CloseSession

func (c *Client) CloseSession(sessionId SessionId) error

func (*Client) Dial

func (c *Client) Dial() error

func (*Client) Download

func (c *Client) Download(filename, saveFile string) error

func (*Client) DownloadAt

func (c *Client) DownloadAt(filename, saveFile string, blockId int) error

func (*Client) GetBlock

func (c *Client) GetBlock(sessionId SessionId, blockId int) ([]byte, error)

func (*Client) Open

func (c *Client) Open(filename string) (SessionId, error)

func (*Client) Read

func (c *Client) Read(sessionId SessionId, buf []byte) (int, error)

func (*Client) ReadAt

func (c *Client) ReadAt(sessionId SessionId, offset int64, size int) ([]byte, error)

func (*Client) Stat

func (c *Client) Stat(filename string) (*StatResponse, error)

type FileRequest

type FileRequest struct {
	Filename string
}

type GetRequest

type GetRequest struct {
	Id      SessionId
	BlockId int
}

type GetResponse

type GetResponse struct {
	BlockId int
	Size    int64
	Data    []byte
}

type ReadCloser

type ReadCloser struct {
	// contains filtered or unexported fields
}

func (*ReadCloser) Close

func (r *ReadCloser) Close() error

func (*ReadCloser) Read

func (r *ReadCloser) Read(buf []byte) (int, error)

func (*ReadCloser) SessionId

func (r *ReadCloser) SessionId() SessionId

type ReadRequest

type ReadRequest struct {
	Id     SessionId
	Offset int64
	Size   int
}

type ReadResponse

type ReadResponse struct {
	Size int
	Data []byte
	EOF  bool
}

type Request

type Request struct {
	Id SessionId
}

type Response

type Response struct {
	Id     SessionId
	Result bool
}

type Rpc

type Rpc struct {
	// contains filtered or unexported fields
}

func (*Rpc) Close

func (r *Rpc) Close(req Request, res *Response) error

func (*Rpc) Open

func (r *Rpc) Open(req FileRequest, res *Response) error

func (*Rpc) Read

func (r *Rpc) Read(req ReadRequest, res *ReadResponse) error

func (*Rpc) ReadAt

func (r *Rpc) ReadAt(req ReadRequest, res *ReadResponse) error

func (*Rpc) Stat

func (r *Rpc) Stat(req FileRequest, res *StatResponse) error

type Server

type Server struct {
	Addr          string
	ReadDirectory string
}

func NewServer

func NewServer(addr, readDirectory string) *Server

func (*Server) ListenAndServe

func (srv *Server) ListenAndServe() error

type Session

type Session struct {
	// contains filtered or unexported fields
}

func (*Session) Add

func (s *Session) Add(file *os.File) SessionId

func (*Session) Delete

func (s *Session) Delete(id SessionId)

func (*Session) Get

func (s *Session) Get(id SessionId) *os.File

func (*Session) Len

func (s *Session) Len() int

type SessionId

type SessionId int64

type StatResponse

type StatResponse struct {
	Type         string
	Size         int64
	LastModified time.Time
}

func (*StatResponse) IsDir

func (r *StatResponse) IsDir() bool

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL