Documentation
¶
Index ¶
- func AppendLineToFile(fileName string, lineToWrite string, permissions int) error
- func CopyFile(sourceFile string, destinationFile string) error
- func CreateDirectory(directoryPath string, permissions uint32) error
- func DeleteDirectory(pathName string) error
- func DeleteFile(fileName string) error
- func DeleteFilesMatchingPattern(fileName string) error
- func DownloadFile(url string, filepath string, header http.Header) error
- func FindMatchingContent(directoryPath string, regexMatchers []string, isFilesIncluded bool, ...) ([]string, error)
- func FindReplaceInFile(filename string, regexMatcher string, replacementValue string) error
- func GetBareDirectoryPath(directoryPath string) string
- func GetBaseDirectory(filePath string) string
- func GetBaseFileName(fileName string) string
- func GetCurrentDirectory(directoryPath string) string
- func GetDefaultCacheDirectory() (string, error)
- func GetFileContents(fileName string) ([]byte, error)
- func GetFileContentsAsBytes(fileName string) ([]byte, error)
- func GetFileExtension(fileName string) string
- func GetFileInstance() fileInstanceType
- func GetFileNameFromPath(fullyQualifiedFileName string) string
- func GetFileSize(fileName string) (int64, error)
- func GetListOfDirectories(directoryPath string, regexMatcher string) ([]string, error)
- func GetListOfDirectoryContents(directoryPath string, regexMatchers []string, isFilesIncluded bool, ...) ([]string, error)
- func GetListOfFiles(directoryPath string, regexMatcher string) ([]string, error)
- func GetNormalizedDirectoryPath(directoryPath string) string
- func GetParentDirectory(fileOrDirectoryPath string) string
- func GetWorkingDirectory() (string, error)
- func IsDirectory(directoryPath string) bool
- func IsDirectoryEmpty(directoryName string) (bool, error)
- func IsDirectoryExists(directoryPath string) bool
- func IsFile(path string) (bool, error)
- func IsFileContainsText(filename string, regexMatcher string) (bool, error)
- func IsFileExists(filePath string) bool
- func MoveFile(sourceFile string, destinationFile string) error
- func RemoveFirstLineFromFile(fileName string) error
- func RenameFile(sourceFileName string, targetFileName string) error
- func WriteBytesToFile(fileName string, bytesToWrite []byte, permissions int) error
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func AppendLineToFile ¶
* AppendLineToFile allows you to append a line to the end of a file. In addition, the following information should be noted:
- In the event the file does not already exist, it will be created for you with the permission attributes provided.
- If you pass in a permissions value of '0', the default value of 666 will be used instead.
func CopyFile ¶
* CopyFile allows you to copy a file from one source location to a target destination location. In the event the operation could not be completed, an error is returned to the user.
func CreateDirectory ¶
* CreateDirectory allows you to create a directory on your local file system.
func DeleteDirectory ¶
DeleteDirectory allows you to recursively remove a directory from the file system.
func DeleteFile ¶
* DeleteFile allows you to delete a file on the file system.
func DeleteFilesMatchingPattern ¶
* DeleteFilesMatchingPattern allows you to delete files matching a specific pattern. Pattern syntax is the same as the 'Match' command.
func DownloadFile ¶
* DownloadFile allows you to download a file from the internet to your local file system.
func FindMatchingContent ¶
func FindMatchingContent(directoryPath string, regexMatchers []string, isFilesIncluded bool, isDirectoriesIncluded bool, isRecursive bool) ([]string, error)
* FindMatchingContent allows you to find matching content from a given directory path. Both shallow and recursive searches are supported and results are returned as a fully qualified path.
func FindReplaceInFile ¶
FindReplaceInFile allows you to find and replace text from within a file. Since this method loads the entire contents of a file into memory, it should only be used for smaller files.
func GetBareDirectoryPath ¶
GetBareDirectoryPath allows you to get a directory path without a trailing slash. This is useful for functions which explicitly need directories formatted this way.
func GetBaseDirectory ¶
* GetBaseDirectory allows you to extract the directory from a file path.
func GetBaseFileName ¶
* GetBaseFileName allows you to extract the base name of a file without any path or file extensions.
func GetCurrentDirectory ¶
GetCurrentDirectory allows you to obtain the current directory from a fully qualified directory path.
func GetDefaultCacheDirectory ¶
GetDefaultCacheDirectory allows you to obtain the cache directory of a user. The cache directory is useful for storing program data that needs to be accessed frequently, but is not terribly important in case it has to be regenerated.
func GetFileContents ¶
GetFileContents allows you to get the entire contents of a file.
func GetFileContentsAsBytes ¶
* GetFileContentsAsBytes allows you to get the contents of a file as a byte array.
func GetFileExtension ¶
* GetFileExtension allows you to get the file extension of a file.
func GetFileInstance ¶
func GetFileInstance() fileInstanceType
GetFileInstance allows you to obtain a file instance to work on.
func GetFileNameFromPath ¶
* GetFileNameFromPath allows you to extract a file name from a fully qualified file path.
func GetFileSize ¶
* GetFileSize allows you to obtain the size of a specified file in bytes.
func GetListOfDirectories ¶
* GetListOfDirectories allows you to obtain a list of files that match a given regular expression.
func GetListOfDirectoryContents ¶
func GetListOfDirectoryContents(directoryPath string, regexMatchers []string, isFilesIncluded bool, isDirectoriesIncluded bool) ([]string, error)
* GetListOfDirectoryContents allows you to obtain a list of files and directories that match a given regular expression.
func GetListOfFiles ¶
* GetListOfFiles allows you to obtain a list of files that match a given regular expression.
func GetNormalizedDirectoryPath ¶
* GetNormalizedDirectoryPath allows you to guarantee that a directory path is always formatted with a trailing slash at the end. This is useful when you need to work with paths in predictable and consistent manner.
func GetParentDirectory ¶
* GetParentDirectory allows you to obtain the container directory of your provided path. This will be everything except the last element of your path.
func GetWorkingDirectory ¶
* GetWorkingDirectory allows you to obtain the current working directory where your program is executing.
func IsDirectory ¶
IsDirectory allows you to check if a disk entry is a directory or not.
func IsDirectoryEmpty ¶
* IsDirectoryEmpty allows you to detect if a directory is empty or not.
func IsDirectoryExists ¶
* IsDirectoryExists allows you to check if a directory exists or not on the file system.
func IsFileContainsText ¶
IsFileContainsText allows you to check if a file contains a matching string or not. Since this method loads the entire contents of a file into memory, it should only be used for smaller files.
func IsFileExists ¶
* IsFileExists allows you to check if a file exists or not on the file system.
func MoveFile ¶
* MoveFile allows you to move a file from one location to another. This method is an alias which simply performs a rename command, which is capable of doing the same action.
func RemoveFirstLineFromFile ¶
RemoveFirstLineFromFile allows you to remove the first line from a file.
func RenameFile ¶
* RenameFile allows you to rename a file on your local file system. In the event that a file with the same name already exists, it will be overwritten. Here we explicitly do the delete so we don't depend on the 'os.Rename' behaviour of overwriting files which may be environment dependant.
func WriteBytesToFile ¶
* WriteBytesToFile allows you to write a series of bytes to a given file. In addition, the following information should be noted:
- In the event the file does not already exist, it will be created for you with the permission attributes provided.
- If you pass in a permissions value of '0', the default value of 666 will be used instead.
Types ¶
This section is empty.