Documentation ¶
Index ¶
- func CopyFileWithUpdate(srcFile, dstFile, startwith, replacement string, appendIfNoMatch bool) result.Result
- func CreateFolderIfNeeded(folderPath string) result.Result
- func CreateOrAppendIfNotInFile(filePath, content string) (bool, error)
- func Exists(filePath string) (bool, error)
- func FloderContent(folderPath string) ([]string, error)
- func FolderExists(folderPath string) (bool, error)
- func FolderFiles(folderPath string) ([]string, error)
- func HomeDir() string
- func IsEmptyFolder(folderPath string) (string, error)
- func ReadFileAsBinary(filePath string) ([]byte, error)
- func ReadFileAsString(filePath string) (string, error)
- func ReadFileAsStringOrEmptyIfNotExists(filePath string) (string, error)
- func RegularFileExists(filePath string) (bool, error)
- func RemoveLineInFile(filePath, startwith string, fullline bool) result.Result
- func StringFileContains(filePath string, content string) (bool, error)
- func SymlinkExists(filePath string) (bool, error)
- func UpdateLineInFile(filePath, startwith, replacement string, appendIfNoMatch bool) result.Result
- func UpdateOrCreateSymlink(existing, linkname string) result.Result
- func WriteBinaryFile(filePath string, newContent []byte, writeIfFileExists bool) result.Result
- func WriteStringFile(filePath, newContent string, overwrite bool) result.Result
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func CopyFileWithUpdate ¶
func CopyFileWithUpdate(srcFile, dstFile, startwith, replacement string, appendIfNoMatch bool) result.Result
CopyFileWithUpdate copies srcFile to dstFile replacing all the lines starting with startwith by replacement.
func CreateFolderIfNeeded ¶
CreateFolderIfNeeded creates a folder if it does NOT exists. Returns a string which describes what has been done, or an error message.
func CreateOrAppendIfNotInFile ¶
CreateOrAppendIfNotInFile checks if a content is already present inside a file. The content MUST be a FULL line (strict line equality) or a set of full lines with a '\n' between them. If the content is already present in the file, the file remains unchanged and the function returns false. Otherwise, the content is appended at the end of the file, and the function returns true.
func FloderContent ¶
FloderContent returns the list of elements (files, folders,...) inside a subtree.
func FolderExists ¶
FolderExists checks if a folder exists. Return true if the folder exists, false otherwise. error != nil if a file exists and is not a folder (ie a regular file or link). TODO : return value is a bit overcomplicated
func FolderFiles ¶
FolderFiles returns the list of regular files inside a subtree.
func HomeDir ¶
func HomeDir() string
HomeDir gets the value of HOME environment variable. Exit(1) on failure.
func IsEmptyFolder ¶
EmptyFolder checks if a folder is empty. Returns a string explaining the folder status NOT_EXIST NOT_FOLDER NOT_EMPTY EMPTY or an error if diagnosis failed
func ReadFileAsBinary ¶
ReadFileAsBinary gets the content of a binary file.
func ReadFileAsString ¶
ReadFileAsString gets the content of a text file.
func ReadFileAsStringOrEmptyIfNotExists ¶
ReadFileAsStringOrEmptyIfNotExists gets the content of a text file. If the file does NOT exists, the method does NOT send an error but returns an empty string.
func RegularFileExists ¶
RegularFileExists checks if a regular file exists. Returns true if the file exists and is a regular file, false otherwise. error != nil if the file exists and is not a regular file (ie a directory). TODO : return value is a bit overcomplicated
func RemoveLineInFile ¶
RemoveLineInFile removes all the lines of filepath which are starting with startwith. if fullline == true, an exact match (instead of start with) is required to remove the line.
func StringFileContains ¶
StringFileContains checks if a content is already present inside a file. The content MUST be a FULL line (with strict line equality) or a set of full lines with a '\n' between them.
func SymlinkExists ¶
SymlinkExists checks if a symbolic link exists. Returns true if the file exists and is a symbolic link, false otherwise. error != nil if the file exists and is not a symbolic link (ie a directory). TODO : return value is a bit overcomplicated
func UpdateLineInFile ¶
UpdateLineInFile replaces all the lines of filepath which are starting with startwith by replacement. if appendIfNoMatch == true, appends the replacement at the end of the file if no replacement have been made before.
func UpdateOrCreateSymlink ¶
UpdateOrCreateSymlink
func WriteBinaryFile ¶
WriteBinaryFile creates a file and writes the content of a byte slice into it. if overwrite == true, replaces the file content if the file exists.
Types ¶
This section is empty.