Documentation
¶
Overview ¶
Package readme provides functions for reading and suggesting readme files.
Index ¶
- func MatchANSI(r io.Reader) (bool, error)
- func ReadPool(art *models.File, sizeLimit int64, download, extra dir.Directory) (*bytes.Buffer, *bytes.Buffer, sauce.Record, error)
- func RemoveCtrls(b []byte) []byte
- func SortList(compact bool, content string) []string
- func Suggest(archive, group string, content string) string
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func MatchANSI ¶ added in v1.9.1
MatchANSI scans for HTML incompatible, ANSI cursor escape codes in the reader.
func ReadPool ¶ added in v1.7.7
func ReadPool( art *models.File, sizeLimit int64, download, extra dir.Directory, ) (*bytes.Buffer, *bytes.Buffer, sauce.Record, error)
ReadPool returns the content of the readme file or the text of the file download. The first buffer is used for CP1252 and ISO-8859-1 texts while the second buffer is used for UTF-8 texts.
The CP1252 and ISO-8859-1 Buffer may also include a FILE_ID.DIZ prefixed metadata. However, the UTF-8 Buffer does get the FILE_ID.DIZ prefix.
func RemoveCtrls ¶
RemoveCtrls removes ANSI escape codes and converts Windows line endings to Unix.
func SortList ¶ added in v1.9.11
SortList returns a sorted list of possible readme text files found in the file archive. The first result is the closes filename to root that has a priority filename extension such as ".nfo", then ordered alphabetically.
When compact is true all filenames using extensions that are not known textfiles, are removed from the slice.
To save memory, content is not split into a slice until we need to handle it.
func Suggest ¶
Suggest returns a suggested readme file name for the record. It prioritizes the filename and group name with a priority extension, such as ".nfo", ".txt", etc. If no priority extension is found, it will return the first text file in the content list.
The archive should be the filename of the archive artifact such as the zip filename. The group should be a name or common abbreviation of the group that released the artifact. The content should be a list of files contained in the artifact.
To save memory, content is not split into a slice until we need to handle it.
This is a port of the CFML function, variables.findTextfile found in File.cfc.
Types ¶
This section is empty.