fs

package
v0.0.0-...-4970bd5 Latest Latest
Warning

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

Go to latest
Published: Dec 3, 2021 License: GPL-2.0 Imports: 12 Imported by: 1

Documentation

Index

Constants

This section is empty.

Variables

Functions

func Build

func Build(m, variable maps.Mapper) (*wrapper, error)

New will extract data from mapper base on following criteria 1. Try to get `fullpath` if any 2. Try to build fullpath with `paths`

func Copy

func Copy(a, b FileSystem) error

func Next

func Next(fs FileSystem, next ...string) []string

func ToObject

func ToObject(data interface{}, config maps.Mapper) maps.Mapper

Types

type FileSystem

type FileSystem interface {
	// full absolute path from root directory
	Abs() string
	// directory path excluded current position
	Dirpath() string
	// upper directory name
	Dirname() string
	// filename with extension
	Basename() string
	// replace basename without extension
	Name() string
	// return relative path from input 'f'
	Relative(f FileSystem) string
	// full path separate by path separator
	Paths() []string

	Type() Type

	IsDir() bool
	IsFile() bool

	// create parent/current directory
	Build() error
	// read files/directories from current position
	ReadDir() ([]FileSystem, error)

	// create file reader
	Reader() (*os.File, error)
	// read content from current file path
	Read() ([]byte, error)
	// create file writer
	Writer() (*os.File, error)
	// write content to current file path
	Write(bs []byte) error

	// read file/directory information
	Stat() (*os.FileInfo, error)
	// modify permission of current file/directory
	Chmod(mode os.FileMode) error
}

func NewDirectories

func NewDirectories(paths [][]string) ([]FileSystem, error)

func NewDirectory

func NewDirectory(paths []string) (FileSystem, error)

func NewFile

func NewFile(paths []string) (FileSystem, error)

func NewFiles

func NewFiles(paths [][]string) ([]FileSystem, error)

func ToFiles

func ToFiles(input []FileSystem) ([]FileSystem, error)

ToFiles will resolve all directory into file The result of this function can be guarantee type file

type Mode

type Mode string
const (
	SINGLE   Mode = "single"
	MULTIPLE Mode = "multiple"
)

func ToMode

func ToMode(s string) (Mode, bool)

type Result

type Result string
const (
	EMPTY_RESULT   Result = "non-valid"
	MISSING_RESULT Result = "missing"
	VALID_RESULT   Result = "valid"
)

type Type

type Type string
const (
	AUTO      Type = "auto"
	FILE      Type = "file"
	DIRECTORY Type = "directory"
)

func ToType

func ToType(s string) (Type, bool)

Jump to

Keyboard shortcuts

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