Documentation
¶
Overview ¶
Package readme provides functions for reading and suggesting readme files.
Index ¶
Constants ¶
This section is empty.
Variables ¶
Functions ¶
func AddPrefix ¶ added in v1.14.0
AddPrefix injects content before the existing byte content. This is usually to inject FILE_ID.DIZ text files.
func AddSuffix ¶ added in v1.14.0
AddSuffix injects content after the existing byte content. This is usually to inject an additional helper text file.
func Normalize ¶ added in v1.14.0
Normalize applies a number of replacements and sanity checks to the byte slice to make it ready for use to display on a user's browser.
- EOF marker is removed
- ASCII NULLs are swapped with spaces
- CFLF newlines are swapped with LF newlines
- Keywords are masked
- SAUCE metadata and comments are removed
- E-grave end of file marker is removed
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 name string should be the original filename of the archive.
- The group should be a known name or common abbreviation,
- The content should be a list of the archive entries.
Types ¶
type Text ¶ added in v1.14.0
type Text struct {
Download dir.Directory
Extra dir.Directory
UUID string
Filename string
Platform string
Section string
Year int16
MaxSize int64
Sign magicnumber.Signature
Record sauce.Record
}
func (*Text) Buffers ¶ added in v1.14.0
Buffers parses the text files assigned to an artifact. There is a possibility of up to three source files: uuid_filename.diz, uuid_filename.txt, uuid_filename.hlp.
Comparing 8-bit IBM Codepage encodings against UTF-8 is unreliable, so after parsing, two buffers are returned:
- buffer 1 contains CP-1252 and ISO-8859-1 friendly text
- buffer 2 contains UTF-8 text using multi-byte characters
Buffer 2 is left empty whenever ANSI encoded or MSDOS binary texts are handled.
If there are no source text files found, or if the found data of the source files is unusable, then the returned buffers will be empty.
Errors are generally logged instead of returned, except with some critical issues. This is to allow the continued rendering of text, say if the ".diz" handler causes an error, Text.Buffers can continue to parse and return the ".txt" and ".hlp" texts.