fs

package
v0.4.1 Latest Latest
Warning

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

Go to latest
Published: Nov 25, 2024 License: MIT Imports: 9 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type FSInfo added in v0.3.0

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

func (*FSInfo) Err added in v0.3.0

func (i *FSInfo) Err() error

Err returns last opertion error on the directory

func (*FSInfo) IsDir added in v0.3.0

func (i *FSInfo) IsDir() bool

IsDir returns true if path points to a directory

func (*FSInfo) ModTime added in v0.3.0

func (i *FSInfo) ModTime() time.Time

ModTime returns the last know modification time.

func (*FSInfo) Mode added in v0.3.0

func (i *FSInfo) Mode() fs.FileMode

Mode returns the fs.FileMode for the directory

func (*FSInfo) Name added in v0.3.0

func (i *FSInfo) Name() string

func (*FSInfo) Path added in v0.3.0

func (i *FSInfo) Path() string

Path is the original path for the directory

func (*FSInfo) Size added in v0.3.0

func (i *FSInfo) Size() int64

Size returns the directory size or -1 if not known or error

type FSPath added in v0.3.0

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

func Path added in v0.3.0

func Path(path string) *FSPath

Path points to a node path

func PathWithVars added in v0.3.0

func PathWithVars(path string, variables *vars.Variables) *FSPath

PathWithVars points to a path and applies variables to the path value

func (*FSPath) Append added in v0.3.0

func (p *FSPath) Append() *FileWriter

Append wraps call to create a new *FileWriter instance for file append operations

func (*FSPath) Dirs added in v0.3.0

func (p *FSPath) Dirs() (infos []*FSInfo)

Dirs returns info about dirs in path

func (*FSPath) Exists added in v0.3.0

func (p *FSPath) Exists() bool

Exists returns true only if os.Stat nil error. Any other scenarios will return false.

func (*FSPath) Info added in v0.3.0

func (p *FSPath) Info() *FSInfo

Info returns information about the specified path

func (*FSPath) MkDir added in v0.3.0

func (p *FSPath) MkDir(mode fs.FileMode) *FSInfo

MkDir creates a directory with file mode at specified

func (*FSPath) Read added in v0.3.0

func (p *FSPath) Read() *FileReader

Read wraps call to create a new *FileReader instance

func (*FSPath) Remove added in v0.3.0

func (p *FSPath) Remove() *FSInfo

Remove removes entry at path

func (*FSPath) Write added in v0.3.0

func (p *FSPath) Write() *FileWriter

Write wraps call to create a new *FileWriter instance

type FileReader

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

func Read

func Read(path string) *FileReader

Read reads the file at path and returns FileReader to access its content

func ReadWithContextVars added in v0.4.1

func ReadWithContextVars(ctx context.Context, path string, variables *vars.Variables) *FileReader

ReadWithContextVars uses specified context and session variables to read the file at path and returns a *FileReader to access its content

func ReadWithVars added in v0.3.0

func ReadWithVars(path string, variables *vars.Variables) *FileReader

ReadWithVars uses session variables to create a new FileReader

func (*FileReader) Bytes

func (fr *FileReader) Bytes() []byte

Bytes returns the content of the file as []byte

func (*FileReader) Err

func (fr *FileReader) Err() error

Err returns an operation error during file read.

func (*FileReader) Info

func (fr *FileReader) Info() os.FileInfo

Info surfaces the os.FileInfo for the associated file

func (*FileReader) Into added in v0.1.1

func (fr *FileReader) Into(w io.Writer) *FileReader

Into reads the content of the file and writes it into the specified Writer

func (*FileReader) Lines

func (fr *FileReader) Lines() []string

Lines returns the content of the file as slice of string

func (*FileReader) SetContext added in v0.4.1

func (fr *FileReader) SetContext(ctx context.Context) *FileReader

SetContext sets the context for the FileReader operations

func (*FileReader) SetVars added in v0.3.0

func (fr *FileReader) SetVars(variables *vars.Variables) *FileReader

SetVars sets the FileReader's session variables

func (*FileReader) String

func (fr *FileReader) String() string

String returns the content of the file as a string value

type FileWriter

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

func Append

func Append(path string) *FileWriter

Append creates FileWriter to write content to file at path

func AppendWitVars added in v0.3.0

func AppendWitVars(path string, variables *vars.Variables) *FileWriter

AppendWithVars uses the specified session variables to create a FileWriter to write content to file at path.

func AppendWithContextVars added in v0.4.1

func AppendWithContextVars(ctx context.Context, path string, variables *vars.Variables) *FileWriter

AppendWithContextVars uses the specified context and session variables to create a new FileWriter that can be used to append content existing file at path. The file will be open with:

os.O_CREATE | os.O_APPEND | os.O_WRONLY

and mode 0644

func Write

func Write(path string) *FileWriter

Write creates a new FileWriter to write file content

func WriteWithContextVars added in v0.4.1

func WriteWithContextVars(ctx context.Context, path string, variables *vars.Variables) *FileWriter

WriteWithVars uses the specified context and session variables to create a new FileWriter that can be used to write content to file at path. The file will be created with:

os.O_CREATE | os.O_TRUNC | os.O_WRONLY

func WriteWithVars added in v0.3.0

func WriteWithVars(path string, variables *vars.Variables) *FileWriter

WriteWithVars uses sesison variables to create a new FileWriter to write content to file

func (*FileWriter) Bytes

func (fw *FileWriter) Bytes(data []byte) *FileWriter

Bytes writes the []bytre provided into the file. Any error can be accessed using FileWriter.Err().

func (*FileWriter) Err

func (fw *FileWriter) Err() error

Err returns FileWriter error during execution

func (*FileWriter) From added in v0.1.1

func (fw *FileWriter) From(r io.Reader) *FileWriter

From streams bytes from the provided io.Reader r and writes them to the file. Any error will be captured and returned by fw.Err().

func (*FileWriter) Info

func (fw *FileWriter) Info() os.FileInfo

Info returns the os.FileInfo for the associated file

func (*FileWriter) Lines

func (fw *FileWriter) Lines(lines []string) *FileWriter

Lines writes the slice of strings into the file. Any error will be captured and returned via FileWriter.Err().

func (*FileWriter) SetVars added in v0.3.0

func (fw *FileWriter) SetVars(variables *vars.Variables) *FileWriter

SetVars sets session variables for FileWriter

func (*FileWriter) String

func (fw *FileWriter) String(str string) *FileWriter

String writes the provided str into the file. Any error that occurs can be accessed with FileWriter.Err().

func (*FileWriter) WithContext added in v0.4.1

func (fw *FileWriter) WithContext(ctx context.Context) *FileWriter

WithContext sets an execution context for the FileWriter operations

func (*FileWriter) WithMode added in v0.3.0

func (fw *FileWriter) WithMode(mode os.FileMode) *FileWriter

Jump to

Keyboard shortcuts

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