file

package
v0.8.4 Latest Latest
Warning

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

Go to latest
Published: Nov 6, 2020 License: LGPL-2.1 Imports: 8 Imported by: 1

Documentation

Overview

Commands for reading and writing files.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Commands

type Commands struct {
	utils.Module
	// contains filtered or unexported fields
}

func New

func New(env utils.Runtime) *Commands

func (*Commands) Read

func (self *Commands) Read(fileOrReader interface{}, args *ReadArgs) (*ReadResponse, error)

func (*Commands) Temp

func (self *Commands) Temp(args *TempArgs) (*os.File, error)

func (*Commands) Write

func (self *Commands) Write(destination interface{}, args *WriteArgs) (*WriteResponse, error)

Write a value or a stream of data to a file at the given path. The destination path can be a local filesystem path, a URI that uses a custom scheme registered outside of the application, or the string "temporary", which will write to a temporary file whose path will be returned in the response.

type ReadArgs added in v0.8.0

type ReadArgs struct {
	// Whether to attempt to close the source (if possible) after reading.
	Autoclose bool `json:"autoclose" default:"true"`

	// The amount of data (in bytes) to read from the readable stream.
	Length int64 `json:"length" default:"-1"`
}

type ReadResponse added in v0.8.0

type ReadResponse struct {
	Data []byte `json:"data"`

	// The length of the data (in bytes).
	Length int64 `json:"length,omitempty"`

	// The amount of time it took to complete reading the data.
	Took time.Duration `json:"took"`
}

type TempArgs

type TempArgs struct {
	// A string to prefix temporary filenames with
	Prefix string `json:"prefix" default:"friendscript-"`
}

type WriteArgs

type WriteArgs struct {
	// The data to write to the destination.
	Data io.Reader `json:"data"`

	// The data to write as a discrete value.
	Value interface{} `json:"value"`

	// Whether to attempt to close the destination (if possible) after reading/writing.
	Autoclose bool `json:"autoclose" default:"true"`
}

type WriteResponse added in v0.8.0

type WriteResponse struct {
	// The filesystem path that the data was written to.
	Path string `json:"path,omitempty"`

	// The size of the data (in bytes).
	Size int64 `json:"size,omitempty"`

	// The amount of time it took to complete writing the data.
	Took time.Duration `json:"took"`
}

Jump to

Keyboard shortcuts

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