Documentation
¶
Overview ¶
Package files: a grab bag of functions for reading and writing files.
grab bag of file utility functions
Index ¶
- Constants
- func Compact(str string) (ret string)
- func FindLatestNameWithTime(dir, prefix, ext string) (ret string, err error)
- func FormattedLoad(inPath string, pv *map[string]any) (err error)
- func FormattedRead(in io.Reader, ext Extension, pv *map[string]any) (err error)
- func FormattedSave(outPath string, data any, pretty bool) (err error)
- func FormattedWrite(w io.Writer, data any, ext Extension, pretty bool) (err error)
- func GetVersion(details bool) (ret string)
- func Indent(str string) (ret string)
- func IsValidExtension(path string, exts []string) (okay bool)
- func LoadJson(inPath string, out any) (err error)
- func LoadTell(inPath string) (ret any, err error)
- func NameWithTime(prefix, ext string) (ret string)
- func ReadFile(path string) ([]byte, error)
- func ReadJson(in io.Reader, out any) (err error)
- func ReadPaths(filePaths string, recusive bool, exts []string, onFile func(string) error) (err error)
- func ReadTell(in io.Reader) (any, error)
- func ReadTellRunes(in io.RuneReader, ofs Ofs, includeComments bool) (ret any, err error)
- func SaveJson(outPath string, data any, pretty bool) (err error)
- func SaveTell(outPath string, data any) (err error)
- func WriteTell(w io.Writer, data any) (err error)
- type Extension
- type JsonFlags
- type Ofs
- type PlainDecoder
- type PlainEncoder
Constants ¶
const SaveFileExtension = ".tap"
Variables ¶
This section is empty.
Functions ¶
func FindLatestNameWithTime ¶
returns the name.ext ( no path ) assumes files are formatted with NameWithTime
func FormattedLoad ¶
write a .if or .tell tapestry file determines the type from the passed path.
func FormattedRead ¶
read a .if or .tell tapestry file
func FormattedSave ¶
write a .if or .tell tapestry file determines the type from the passed path.
func FormattedWrite ¶
write a .if or .tell story file
func GetVersion ¶
for lack of a better place... here we arere.
func IsValidExtension ¶
is the extension of the passed path one of the specified extensions?
func NameWithTime ¶
golang doesn't provide file creation time in a cross-platform way so we add the current time to the name ( base 36 ) future: include a user specified tag ( separated by a hash or something. )
func ReadPaths ¶
func ReadPaths(filePaths string, recusive bool, exts []string, onFile func(string) error) (err error)
read a comma-separated list of files and directories for directories, ext ( a list of file extensions ) optionally filters the files. fix? maybe filepaths could be turned into an io.fs?
func ReadTellRunes ¶
reads until the passed reader is exhausted ( hits eof ) returns nil error when finished. includeComments helps with testing
Types ¶
type Extension ¶
type Extension int
func SplitExt ¶
given a file name, return its extension and the name without the extension. 0, Invalid if it isn't a known extension.
type PlainDecoder ¶
type PlainEncoder ¶
matches https://pkgo.dev/encoding/json#Encoder.Encode
func JsonEncoder ¶
func JsonEncoder(w io.Writer, f JsonFlags) PlainEncoder
func TellEncoder ¶
func TellEncoder(w io.Writer) PlainEncoder