Documentation
¶
Index ¶
- Variables
- type Files
- func (f *Files) CreateDirectory(directory string) error
- func (f *Files) Delete(path string)
- func (f *Files) DeleteIfEmpty(path string)
- func (f *Files) Exists(path string) bool
- func (f *Files) FileOrDirectoryExists(path string) (bool, error)
- func (f *Files) GetCurrentDirectory() string
- func (f *Files) GetDirectoriesFromRoot(root string) ([]string, error)
- func (f *Files) GetDirectoryName(path string) string
- func (f *Files) GetFileExtension(extensionOrPath string) string
- func (f *Files) GetFileName(path string) string
- func (f *Files) GetFileNameWithoutExtension(fileName string) string
- func (f *Files) GetFullPath(file string) string
- func (f *Files) GetLength(path string) int64
- func (f *Files) IsFileEmpty(path string) bool
- func (f *Files) IsText(extensionOrPath string) bool
- func (f *Files) Move(sourcePath, destPath string)
- func (f *Files) ReadFile(filePath string) []byte
- func (f *Files) TryCreateFile(path string, useEmptyStringForTextFiles bool) bool
- func (f *Files) WriteStream(path string, stream []byte)
- func (f *Files) WriteText(filePath string, text string)
- type Guards
Constants ¶
This section is empty.
Variables ¶
var File = Files{}
File an instance of the Files struct.
var Guard = Guards{}
Guard an instance of the Guards struct.
Functions ¶
This section is empty.
Types ¶
type Files ¶
type Files struct {
}
Files struct that provides file helper functions
func (*Files) CreateDirectory ¶
CreateDirectory creates a directory
func (*Files) DeleteIfEmpty ¶
DeleteIfEmpty deletes the file at the path if it is empty
func (*Files) FileOrDirectoryExists ¶
FileOrDirectoryExists checks if a file or directory exists
func (*Files) GetCurrentDirectory ¶
GetCurrentDirectory returns the current directory
func (*Files) GetDirectoriesFromRoot ¶
GetDirectoriesFromRoot returns the list of directories in a root directory, including all inner sub-directories
func (*Files) GetDirectoryName ¶
func (*Files) GetFileExtension ¶
GetFileExtension returns the extension of the file
func (*Files) GetFileName ¶
GetFileName returns the name of the file from the path
func (*Files) GetFileNameWithoutExtension ¶
GetFileNameWithoutExtension returns the name of the file without its extension.
func (*Files) GetFullPath ¶
GetFullPath returns the full path to the file
func (*Files) IsFileEmpty ¶
IsFileEmpty checks if the file at the path is empty
func (*Files) TryCreateFile ¶
TryCreateFile creates a file at the path. If useEmptyStringForTextFiles is set and the file extension is text, creates an empty file with the provided name.
func (*Files) WriteStream ¶
WriteStream writes a stream to a file
type Guards ¶
type Guards struct {
}
Guards struct that provides guard helper functions
func (*Guards) AgainstBadExtension ¶
AgainstBadExtension guards agaist having a "." in the provided file extension.
func (*Guards) AgainstEmpty ¶
AgainstEmpty guards against string being empty
func (*Guards) AgainstNullOrEmptySlice ¶
AgainstNullOrEmptySlice guards against the slice being nil or having zero length
func (*Guards) FileExists ¶
FileExists checks if a file exists at the provided path
func (*Guards) GuardFiles ¶
GuardFiles checks if the files exists and the have content