fs

package module
v0.0.0-...-a114629 Latest Latest
Warning

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

Go to latest
Published: Feb 12, 2023 License: BSD-3-Clause Imports: 11 Imported by: 4

Documentation

Index

Constants

This section is empty.

Variables

Functions

func Build

func Build(m, variable mapper.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 BuildMFpMap

func BuildMFpMap(fp string) mapper.Mapper

Build multiple 'file or directory' full path map

func BuildMPMap

func BuildMPMap(paths ...[]string) mapper.Mapper

Build multiple 'file or directory' path list map

func BuildMdFpMap

func BuildMdFpMap(fp string) mapper.Mapper

Build multiple directory full path map

func BuildMdPMap

func BuildMdPMap(paths ...[]string) mapper.Mapper

Build multiple directory path list map

func BuildMfFpMap

func BuildMfFpMap(fp string) mapper.Mapper

Build multiple file full path map

func BuildMfPMap

func BuildMfPMap(paths ...[]string) mapper.Mapper

Build multiple file path list map

func BuildSFpMap

func BuildSFpMap(fp string) mapper.Mapper

Build single 'file or directory' full path map

func BuildSPMap

func BuildSPMap(paths ...string) mapper.Mapper

Build single 'file or directory' path list map

func BuildSdFpMap

func BuildSdFpMap(fp string) mapper.Mapper

Build single file full path map

func BuildSdPMap

func BuildSdPMap(paths ...string) mapper.Mapper

Build single file path list map

func BuildSfFpMap

func BuildSfFpMap(fp string) mapper.Mapper

Build single file full path map

func BuildSfPMap

func BuildSfPMap(paths ...string) mapper.Mapper

Build single file path list map

func Copy

func Copy(a, b FileSystem) error

func Next

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

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