fsys

package
v1.0.10 Latest Latest
Warning

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

Go to latest
Published: Feb 18, 2024 License: MIT Imports: 5 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type FS

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

FS is a file system operations wrapper. Wrap for testing.

func New added in v1.0.10

func New(opts ...func(*Option)) *FS

New returns a new file system.

func (FS) Exists added in v1.0.10

func (f FS) Exists(p string) bool

Exists returns true if the file exists.

func (FS) Read

func (f FS) Read(p string) (io.ReadCloser, error)

Read returns a file for reading.

func (FS) RemoveAll added in v1.0.10

func (f FS) RemoveAll(p string) error

RemoveAll removes a file.

func (FS) Write

func (f FS) Write(p string, flag int) (io.WriteCloser, error)

Write returns a file for writing. flag:

  • os.O_CREATE|os.O_WRONLY|os.O_TRUNC for rewrite file
  • os.O_CREATE|os.O_APPEND|os.O_WRONLY for append file

type File

type File string

File is a file wrapper.

func (File) Empty

func (f File) Empty() bool

Empty returns true if the file is empty.

func (File) IsAbs

func (f File) IsAbs() bool

IsAbs returns true if the file path is absolute.

func (File) Path

func (f File) Path() string

Path returns the file path.

func (File) Rel

func (f File) Rel() string

Rel returns the relative path to the file.

func (File) String

func (f File) String() string

String returns the string representation of the file.

type Option added in v1.0.10

type Option struct {
	Write  func(string, int) (io.WriteCloser, error)
	Read   func(string) (io.ReadCloser, error)
	Remove func(string) error
	Exists func(string) bool
}

Option is a file system option.

Jump to

Keyboard shortcuts

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