filereader

package
v0.0.0-...-1af4f67 Latest Latest
Warning

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

Go to latest
Published: Dec 15, 2021 License: MIT Imports: 6 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func NewFileReader

func NewFileReader(path, extension string, bufSiz uint) (*FileReader, *Error)

NewFileReader creates a new FileReader. Please do not create a FileReader directly. "path" - a directory to read all files from, filtered by "extension" ("path" may be relative). "bufSiz" - maximum size of a file, in bytes (if this value is too small, a bytearray can be truncated) Example: NewFileReader("descriptions/texts", "txt", 2048)

Types

type FileReader

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

FileReader is a component that reads files from disk and stores them in memory as a bytearray. This component is independent.

func (*FileReader) GetByName

func (reader *FileReader) GetByName(name string) (res []byte, ok bool)

GetByName returns file content by a given file name

func (*FileReader) GetRandomAmong

func (reader *FileReader) GetRandomAmong(among ...string) (string, *Error)

GetRandomAmong returns a random file name from the list of loaded files, that also is present in "among" parameter.

func (*FileReader) GetRandomExcept

func (reader *FileReader) GetRandomExcept(excepts ...string) (string, *Error)

GetRandomExcept returns a random file name from the list of loaded files, except specified as "excepts" parameter.

Jump to

Keyboard shortcuts

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