Documentation ¶
Overview ¶
Package file provides util primitives to file operations.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func CleanseFolderFileName ¶ added in v1.1.4
CleanseFolderFileName is a helper function that ensures folders' and files' names are valid, that they do not contain prohibited characters. However, some are still not caught for unlikeliness and simplicity reasons. The following are reserved file names for Windows that are uncaught: CON, PRN, AUX, NUL, COM1, COM2, COM3, COM4, COM5, COM6, COM7, COM8, COM9, LPT1, LPT2, LPT3, LPT4, LPT5, LPT6, LPT7, LPT8, LPT9. The following are non-printable characters that are uncaught: ASCII 0-31.
func DecodeStructFromFile ¶
DecodeStructFromFile takes a file that has been encoded by a struct and decodes it back to the struct. Provide absolute path else file may not be found.
func EncodeStructToFile ¶
EncodeStructToFile takes in any struct and encodes it into a file specified by fileName. If the file already exists, it is truncated. If the file does not exist, it is created with mode 0666 (before umask). Provide absolute path else file will be written to the current working directory.
Types ¶
type FileNotFoundError ¶
type FileNotFoundError struct {
FileName string
}
FileNotFoundError struct is an error struct that contains the custom error that will be thrown when file is not found.
func (*FileNotFoundError) Error ¶
func (e *FileNotFoundError) Error() string
FileNotFoundError is an error that will be thrown when file is not found.