fsutils

package
v0.0.0-...-790a62a Latest Latest
Warning

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

Go to latest
Published: May 2, 2024 License: MIT Imports: 10 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ABS

func ABS(path string) (abspath string, err error)

ABS return absolute path from relative path

func APPEND

func APPEND(path string, a ...interface{}) (err error)

APPEND if file exists append content else create file and append content

func CAT

func CAT(path string, a ...interface{}) (r io.Reader, err error)

CAT return file content if file exists else empty string

func CATS

func CATS(path string, a ...interface{}) (cntnt string, err error)

CATS return file content if file exists else empty string

func EXISTS

func EXISTS(path string) (pathexists bool, err error)

EXISTS return true if path exists

func FINDROOT

func FINDROOT(path string, altpath ...interface{}) (root string, err error)

func FINDROOTS

func FINDROOTS(path string, altpaths ...interface{}) (roots []string, err error)

func FINFOPATHSJSON

func FINFOPATHSJSON(a ...FileInfo) (s string)

FINFOPATHSJSON []FileInfo to JSON array

func MKDIR

func MKDIR(path string) error

MKDIR make directory

func MKDIRALL

func MKDIRALL(path string) error

MKDIRALL make directory with all necessary parents

func MULTICAT

func MULTICAT(path ...string) (r io.Reader, err error)

MULTICAT return file(s) content if file(s) exists else empty string

func MULTICATS

func MULTICATS(path ...string) (cntnt string, err error)

MULTICATS return file(s) content if file(s) exists else empty string

func MV

func MV(path string, destpath string) (err error)

MV Move file or directory

func PIPE

func PIPE(path string, a ...interface{}) (r io.Reader, err error)

PIPE return file content if file exists else empty string

func PIPES

func PIPES(path string, a ...interface{}) (cntnt string, err error)

PIPES return file content if file exists else empty string

func RM

func RM(path string) (err error)

RM Remove file or directory recursive

func SET

func SET(path string, a ...interface{}) (err error)

SET if file exists replace content else create file and append content

func TOUCH

func TOUCH(path string) (err error)

TOUCH Create an empty file if the file doesn’t already exist or if the file already exists then update the modified time of the file

Types

type FSUtils

type FSUtils struct {
	EXISTS         func(path string) bool                                                                                                                                `json:"exists"`
	ABS            func(path string) string                                                                                                                              `json:"abs"`
	LS             func(path ...interface{}) (finfos []FileInfo)                                                                                                         `json:"ls"`
	FIND           func(path ...interface{}) (finfos []FileInfo)                                                                                                         `json:"find"`
	FINDROOT       func(path ...interface{}) (root string)                                                                                                               `json:"findroot"`
	FINDROOTS      func(path ...interface{}) (roots []string)                                                                                                            `json:"findroots"`
	MKDIR          func(path ...interface{}) bool                                                                                                                        `json:"mkdir"`
	MKDIRALL       func(path ...interface{}) bool                                                                                                                        `json:"mkdirall"`
	RM             func(path string) bool                                                                                                                                `json:"rm"`
	MV             func(path string, destpath string) bool                                                                                                               `json:"mv"`
	TOUCH          func(path string) bool                                                                                                                                `json:"touch"`
	FINFOPATHSJSON func(a ...FileInfo) (s string)                                                                                                                        `json:"finfopathsjson"`
	PIPE           func(path string, a ...interface{}) (r io.Reader)                                                                                                     `json:"pipe"`
	PIPES          func(path string, a ...interface{}) (s string)                                                                                                        `json:"pipes"`
	CAT            func(path string, a ...interface{}) (r io.Reader)                                                                                                     `json:"cat"`
	MULTICAT       func(path ...string) (r io.Reader)                                                                                                                    `json:"multicat"`
	CATS           func(path string, a ...interface{}) (s string)                                                                                                        `json:"cats"`
	MULTICATS      func(path ...string) (s string)                                                                                                                       `json:"multicats"`
	SET            func(path string, a ...interface{}) bool                                                                                                              `json:"set"`
	APPEND         func(path string, a ...interface{}) bool                                                                                                              `json:"append"`
	DUMMYFINFO     func(name string, path string, absolutepath string, size int64, mod os.FileMode, modtime time.Time, active bool, raw bool, a ...interface{}) FileInfo `json:"dummyfino"`
}

FSUtils struct

func NewFSUtils

func NewFSUtils() (fsutlsstrct FSUtils)

NewFSUtils return instance of FSUtils

type FileInfo

type FileInfo interface {
	Name() string         // base name of the file
	Path() string         // relative path of the file
	PathExt() string      //relative path extension of the file
	PathRoot() string     // relative path root of the file
	Root() string         // relative path root of the file
	AbsolutePath() string // absolute path of the file
	Size() int64          // length in bytes for regular files; system-dependent for others
	Mode() os.FileMode    // file mode bits
	ModTime() time.Time   // modification time
	IsDir() bool          // abbreviation for Mode().IsDir()
	JSON() string         //json representation as a string
	IsActive() bool
	IsRaw() bool
	Open(...interface{}) (io.ReadCloser, error)
}

A FileInfo describes a file

func FIND

func FIND(path string, a ...interface{}) (finfos []FileInfo, err error)

FIND list recursive dir content

func LS

func LS(path string, altpaths ...interface{}) (finfos []FileInfo, err error)

LS List dir content

Jump to

Keyboard shortcuts

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