local

package
v0.31.1 Latest Latest
Warning

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

Go to latest
Published: Nov 26, 2025 License: MIT Imports: 14 Imported by: 1

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ListFiles

func ListFiles(pth string) ([]stat.Stats, error)

ListFiles will list all files in the provided pth directory. pth must be a directory.

Will not list recursively Checksums are not returned.

func Stat added in v0.5.0

func Stat(pth string) (stat.Stats, error)

Stat returns a summary stats of a file or directory. It can be used to verify read permissions

Types

type Reader

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

func NewReader

func NewReader(pth string) (*Reader, error)

func (*Reader) Close

func (r *Reader) Close() (err error)

func (*Reader) Read

func (r *Reader) Read(p []byte) (n int, err error)

func (*Reader) ReadLine

func (r *Reader) ReadLine() (ln []byte, err error)

func (*Reader) Stats

func (r *Reader) Stats() stat.Stats

type Writer

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

func NewWriter

func NewWriter(pth string, opt *buf.Options) (*Writer, error)

NewWriter will create a new local writer. - 'pth' is the full path (with filename) that will be written. If the final file extension is a supported compression format then the file will be compressed in that format. - 'append' indicates whether the write session will append the contents to an existing file or truncate and then write. The default is false which will truncate an existing file and then write. - 'lazy' set to 'true' will tell the writer to do a lazy write. This means that all write calls will write to memory first and then write to 'pth' when writing is complete with a final call to 'Close'. If Close is never called then the file will not be written.

When initializing a new writer, pth is checked for the correct write permissions. An error is returned if the writer will not have the correct permissions.

For lazy writing, the writer supports writing to memory or a temp file. The writer will use the temp file option if tmpDir and/or tmpPrefix is provided. The writer will remove a temp file with a call to Close.

func (*Writer) Abort

func (w *Writer) Abort() error

Abort will: - clear and close buffer - prevent further writing

func (*Writer) Close

func (w *Writer) Close() error

Close will: - calculate final checksum - set file size - set file created date - copy (mv) buffer to pth file - clear and close buffer - report any errors

Calling Abort after Close will do nothing. Writing after Close will not write and will not return a nil-error.

func (*Writer) Stats

func (w *Writer) Stats() stat.Stats

func (*Writer) Write

func (w *Writer) Write(p []byte) (n int, err error)

func (*Writer) WriteLine

func (w *Writer) WriteLine(ln []byte) (err error)

Jump to

Keyboard shortcuts

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