Documentation ¶
Index ¶
- Constants
- Variables
- type File
- type Fileinfo
- type Filelist
- type RRFFileManager
- func (r *RRFFileManager) Connect(ctx context.Context, password string) error
- func (r *RRFFileManager) Delete(ctx context.Context, path string) error
- func (r *RRFFileManager) Download(ctx context.Context, path string) ([]byte, *time.Duration, error)
- func (r *RRFFileManager) Fileinfo(ctx context.Context, path string) (*Fileinfo, error)
- func (r *RRFFileManager) Filelist(ctx context.Context, dir string, recursive bool) (*Filelist, error)
- func (r *RRFFileManager) Mkdir(ctx context.Context, path string) error
- func (r *RRFFileManager) Move(ctx context.Context, oldpath, newpath string) error
- func (r *RRFFileManager) Upload(ctx context.Context, path string, content io.Reader) (*time.Duration, error)
Constants ¶
const (
// TimeFormat is the format of timestamps used by RRF
TimeFormat = "2006-01-02T15:04:05"
)
Variables ¶
var ErrDirectoryNotFound = errors.New("Directory not found")
ErrDirectoryNotFound is the error returned if a directory was not found
var ErrDriveNotMounted = errors.New("Drive not mounted")
ErrDriveNotMounted is the error returned if the requested drive is not mounted
var ErrFileNotFound = errors.New("File not found")
ErrFileNotFound is the error returned in case a call to the rr_fileinfo interface was successful but returned err != 0
Functions ¶
This section is empty.
Types ¶
type File ¶
type File struct { // Type of file - can be file or directory Type string // Name of file Name string // Size of file in bytes Size uint64 // Timestamp corresponds to last modification date Timestamp localTime `json:"date"` }
File resembles the JSON object returned in the files property of the rr_filelist response
type Fileinfo ¶
type Fileinfo struct { // Err holds a numeric error code where 0 means no error Err uint64 // Size is the size of a file in bytes (0 for directories) Size uint64 Timestamp localTime `json:"lastModified"` // Height in mm for a job file Height float64 // FirstLayerHeight in mm for a job file FirstLayerHeight float64 // LayerHeight in mm for a job file LayerHeight float64 // PrintTime in seconds for a job file PrintTime uint64 // Filament contains an array of used filaments in mm Filament []float64 // GeneratedBy returns the string which application created the job file GeneratedBy string }
Fileinfo is the structure returned at rr_fileinfo interface
func (*Fileinfo) LastModified ¶
LastModified returns the last modification time of this file
type Filelist ¶
type Filelist struct { Dir string Files []File Next uint64 Err uint64 Subdirs []*Filelist // contains filtered or unexported fields }
Filelist resembled the JSON object in rr_filelist
type RRFFileManager ¶
type RRFFileManager struct {
// contains filtered or unexported fields
}
RRFFileManager provides means to interact with SD card contents on a machine using RepRapFirmware (RRF). It will communicate through its HTTP interface.
func New ¶
func New(domain string, port uint64, debug bool) *RRFFileManager
New creates a new instance of RRFFileManager
func (*RRFFileManager) Connect ¶
func (r *RRFFileManager) Connect(ctx context.Context, password string) error
Connect establishes a connection to RepRapFirmware
func (*RRFFileManager) Delete ¶
func (r *RRFFileManager) Delete(ctx context.Context, path string) error
Delete removes the given path. It will fail for non-empty directories.
func (*RRFFileManager) Download ¶
GetFile downloads a file with the given path also returning the duration of this action
func (*RRFFileManager) Fileinfo ¶
Fileinfo returns information on a given file or an error if the file does not exist
func (*RRFFileManager) Filelist ¶
func (r *RRFFileManager) Filelist(ctx context.Context, dir string, recursive bool) (*Filelist, error)
Filelist will download a list of all files (also including directories) for the given path. If recursive is true it will also populate the field Subdirs of Filelist to contain the full tree.
func (*RRFFileManager) Mkdir ¶
func (r *RRFFileManager) Mkdir(ctx context.Context, path string) error
Mkdir creates a new directory with the given path