fileio

package
v0.0.0-...-2e3fc24 Latest Latest
Warning

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

Go to latest
Published: May 3, 2024 License: Apache-2.0 Imports: 16 Imported by: 0

Documentation

Index

Constants

View Source
const (

	// defaultFilePermissions houses the default mode to use when no file permissions are provided
	DefaultFilePermissions os.FileMode = 0o644
)

Variables

This section is empty.

Functions

func DecodeIgnitionFileContents

func DecodeIgnitionFileContents(source, compression *string) ([]byte, error)

func NewIgnFileBytes

func NewIgnFileBytes(path string, contents []byte, mode os.FileMode) ign3types.File

NewIgnFileBytes is like NewIgnFile, but accepts binary data

Types

type Reader

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

Reader is a struct for reading files from the device

func NewReader

func NewReader() *Reader

New creates a new writer

func (*Reader) CheckPathExists

func (r *Reader) CheckPathExists(filePath string) error

CheckPathExists checks if a path exists and will return an error if either the file does not exist or if there is an error checking the path.

func (*Reader) PathFor

func (r *Reader) PathFor(filePath string) string

PathFor returns the full path for the provided file, useful for using functions and libraries that don't work with the fileio.Reader

func (*Reader) ReadFile

func (r *Reader) ReadFile(filePath string) ([]byte, error)

ReadFile reads the file at the provided path

func (*Reader) SetRootdir

func (r *Reader) SetRootdir(path string)

SetRootdir sets the root directory for the reader, useful for testing

type Writer

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

Writer is responsible for writing files to the device

func NewWriter

func NewWriter() *Writer

New creates a new writer

func (*Writer) SetRootdir

func (w *Writer) SetRootdir(path string)

SetRootdir sets the root directory for the writer, useful for testing

func (*Writer) WriteFile

func (w *Writer) WriteFile(name string, data []byte, perm fs.FileMode) error

WriteFile writes the provided data to the file at the path with the provided permissions

func (*Writer) WriteIgnitionFiles

func (w *Writer) WriteIgnitionFiles(files ...ign3types.File) error

WriteIgnitionFiles writes the provided files to the device

Jump to

Keyboard shortcuts

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