Documentation ¶
Overview ¶
Package files provides standard file functions
Index ¶
- func CheckIfExists(dir string) bool
- func CopyFileContents(src, dst string) (err error)
- func CreateDirsIfNotExists(d []string) error
- func DownloadFile(url string, writefile string, interactive bool) error
- func LoadToml(tomlFile string) (*toml.Tree, error)
- func ProcessFileOptions(filename string, options Bits) error
- func SafeRename(origDir string) error
- func SaveToml(tree *toml.Tree, tomlFile string) error
- func WriteToFile(filename string, data string, options Bits) error
- func WriteToFilePrivate(filename string, data string) error
- type Bits
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func CheckIfExists ¶
CheckIfExists checks if a file / directory exists
func CopyFileContents ¶
CopyFileContents writes the contents from src to a new file dst. This operation is silently destructive
func CreateDirsIfNotExists ¶
CreateDirsIfNotExists takes an array of strings containing filepaths and for any path that contains directories which do not exist, it creates them.
func DownloadFile ¶
DownloadFile downs a file from a URL and writes it to disk
func ProcessFileOptions ¶ added in v0.3.0
ProcessFileOptions decides what to do with an existing file before any modifications (create, copy, move, delete, update), based on the options provided. If the OverwriteSilently bit is set, this function does nothing, allowing the file to be silently modified later. Otherwise, if the PromptIfExisting bit is set, the user is interactively prompted for confirmation (yes/no). If the BackupExisting flag is set, the file is also backed-up.
func SafeRename ¶ added in v0.3.0
SafeRename renames a folder or file to <name>.~n~ where n is the lowest value where the folder does not already exist. The value of n is capped at 100, which would require the user to manually tidy the parent folder.
func WriteToFile ¶
WriteToFile calls ProcessFileOptions before writing a string variable to a file.
func WriteToFilePrivate ¶
WriteToFilePrivate writes a string variable to a file with 0600 permissions. It creates all directories along the path if they don't exist.