Docs, docs, docs!

This commit is contained in:
nemunaire 2018-05-12 01:08:37 +02:00
parent 12a85ee804
commit dcb67fba63
7 changed files with 38 additions and 2 deletions

View file

@ -24,15 +24,22 @@ type Importer interface {
exists(filename string) bool
// toURL gets the full path/URL to the given file, the Importer will look internaly (used for debuging purpose).
toURL(filename string) string
// importFile imports the file at the given URI
// importFile imports the file at the given URI, inside the global FILES/ directory.
// Then calls back the next function, with the downloaded location and the original URI.
// Callback return is forwarded.
importFile(URI string, next func(string, string) (interface{}, error)) (interface{}, error)
// getFile write to the given buffer, the file at the given location.
getFile(filename string, writer *bufio.Writer) error
// listDir returns a list of the files and subdirectories contained inside the directory at the given location.
listDir(filename string) ([]string, error)
// stat returns many information about the given file: such as last modification date, size, ...
stat(filename string) (os.FileInfo, error)
}
// GlobalImporter stores the main importer instance to use for global imports.
var GlobalImporter Importer
// getFile helps to manage huge file transfert by concatenating splitted (with split(1)) files.
func getFile(i Importer, URI string, writer *bufio.Writer) error {
// Import file if it exists
if i.exists(URI) {
@ -67,7 +74,7 @@ func getFile(i Importer, URI string, writer *bufio.Writer) error {
return errors.New(fmt.Sprintf("%q: no such file or directory", URI))
}
// getFileContent
// getFileContent retrieves the content of the given text file.
func getFileContent(i Importer, URI string) (string, error) {
cnt := bytes.Buffer{}