fsadapter

package
v2.0.0 Latest Latest
Warning

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

Go to latest
Published: Jun 11, 2022 License: GPL-3.0 Imports: 10 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrIllegalDir = errors.New("illegal file path reference outside of working directory")

Functions

func Close

func Close(fs FS) error

Close closes the filesystem, if it implements the io.Closer interface.

Types

type Directory

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

func NewDirectory

func NewDirectory(dir string) Directory

func (Directory) Create

func (fs Directory) Create(fpath string) (io.WriteCloser, error)

func (Directory) String

func (d Directory) String() string

func (Directory) WriteFile

func (fs Directory) WriteFile(name string, data []byte, perm os.FileMode) error

type FS

type FS interface {
	Create(string) (io.WriteCloser, error)
	WriteFile(name string, data []byte, perm os.FileMode) error
}

FS is interface for operating on the files of the underlying filesystem.

func ForFilename

func ForFilename(name string) (FS, error)

ForFilename returns appropriate filesystem based on the name of the file or directory given. Logic is simple:

  • if file has a known extension, the appropriate adapter will be returned.
  • else: it's a directory.

type ZIP

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

func NewZIP

func NewZIP(zw *zip.Writer) *ZIP

func NewZipFile

func NewZipFile(filename string) (*ZIP, error)

func (*ZIP) Close

func (z *ZIP) Close() error

Close closes the underlying zip writer and the file handle. It is only necessary if ZIP was initialised using NewZipFile

func (*ZIP) Create

func (z *ZIP) Create(filename string) (io.WriteCloser, error)

func (*ZIP) String

func (z *ZIP) String() string

func (*ZIP) WriteFile

func (z *ZIP) WriteFile(filename string, data []byte, _ os.FileMode) error

Jump to

Keyboard shortcuts

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