fileloader

package
v0.9.7 Latest Latest
Warning

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

Go to latest
Published: Jul 14, 2025 License: GPL-3.0 Imports: 11 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CopyFileContents

func CopyFileContents(src, dst string) (err error)

func LoadAllFlatFiles

func LoadAllFlatFiles[K comparable, T Loadable[K]](basePath string, filePattern ...string) (map[K]T, error)

Will check the ID() of each item to make sure it's unique

func LoadAllFlatFilesSimple

func LoadAllFlatFilesSimple[T LoadableSimple](basePath string, filePattern ...string) ([]T, error)

LoadAllFlatFilesSimple doesn't require a unique Id() for each item

func LoadFlatFile

func LoadFlatFile[T LoadableSimple](path string) (T, error)

func SaveAllFlatFiles

func SaveAllFlatFiles[K comparable, T Loadable[K]](basePath string, data map[K]T, saveOptions ...SaveOption) (int, error)

Returns the number of files saved and error

func SaveFlatFile

func SaveFlatFile[T LoadableSimple](basePath string, dataUnit T, saveOptions ...SaveOption) error

Returns the number of files saved and error

Types

type FileType

type FileType uint8

type Loadable

type Loadable[K comparable] interface {
	Id() K // Must be a unique identifier for the data
	LoadableSimple
}

type LoadableSimple

type LoadableSimple interface {
	Validate() error  // General validation (or none)
	Filepath() string // Relative file path to some base directory - can include subfolders
}

type ReadableGroupFS

type ReadableGroupFS interface {
	fs.ReadFileFS
	AllFileSubSystems(yield func(fs.ReadFileFS) bool)
}

implements fs.ReadFileFS implements an iterator function as well

type SaveOption

type SaveOption uint8
const (
	// Save options
	SaveCareful SaveOption = iota // Save a backup and rename vs. just overwriting
)

Jump to

Keyboard shortcuts

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