Documentation
¶
Index ¶
- func DirEmpty(dir string) (is_empty bool)
- func DirExists(dir string) (exists bool)
- func DirSize(path string) (size int64, err error)
- func DirsAdd(baseDir string, dirs []string)
- func IsEmpty(dir string) bool
- func List(dir string, only_dirs bool) (files []string)
- func ShowTestResult(got, want any, t *testing.T)
- func ShowTestResultDeepEqual(got, want any, t *testing.T)
- type Clean
- type Dir
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func DirEmpty ¶
DirEmpty checks if the given directory is empty by delegating the check to the IsEmpty function. It returns true if the directory is empty, false otherwise.
func DirExists ¶
DirExists checks if the specified directory exists on the file system. It returns `true` if the directory exists, and `false` if it does not. If an error occurs while checking, the function returns `false` without panicking.
func DirSize ¶
DirSize calculates the total size of the specified directory and its contents (including subdirectories). It returns the total size in bytes, as well as any error encountered during the traversal of the directory. If an error occurs while walking the directory, the error is returned alongside the calculated size (which may be zero).
func DirsAdd ¶
DirsAdd creates one or more directories, along with any necessary parent directories. It takes a base directory path (`baseDir`) and a slice of subdirectory names (`dirs`), and attempts to create each of the subdirectories inside the base directory. If an error occurs while creating any directory, the error is printed to the console.
func IsEmpty ¶
IsEmpty checks whether the given directory is empty. It returns true if the directory contains only itself and no other files or directories.
func List ¶
List returns a list of all files and directories in the specified directory. If only_dirs is true, only directories will be included in the returned list. If only_dirs is false, both files and directories will be included.
func ShowTestResult ¶
ShowTestResult compares the expected and actual results, printing an error message if they differ.
func ShowTestResultDeepEqual ¶
Use cmp.Equal instead?
Types ¶
type Clean ¶
type Clean struct {
SourceFile string // The source file to be transferred or deleted.
TargetFile string // The target file for transfer.
}
Clean represents a structure for cleaning files by transferring or deleting them.
func (*Clean) FileDelete ¶
FileDelete deletes the SourceFile from the system.
func (*Clean) FileTransfer ¶
FileTransfer moves a file from SourceFile to TargetFile.
type Dir ¶
type Dir struct {
OS string
}
func (*Dir) GetDesktop ¶
GetDesktop returns the path to the "Desktop" directory for the current user. It constructs the path by combining the user's home directory with the "Desktop" subdirectory. If there is an error retrieving the user's home directory, the function will panic.
func (*Dir) GetDownloads ¶
GetDownloads returns the path to the "Downloads" directory for the current user. It constructs the path by combining the user's home directory with the "Downloads" subdirectory. If there is an error retrieving the user's home directory, the function will panic.
func (*Dir) GetTrash ¶
GetTrash returns the path to the "Trash" directory based on the operating system. It constructs the trash path by combining the user's home directory with the appropriate subdirectory: - On macOS ("darwin"), it returns the `.Trash` directory. - On Linux, it returns the `.local/share/Trash` directory. If the OS is unsupported or there is an error retrieving the user's home directory, the function will panic.