core

package
v0.1.2 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: May 22, 2025 License: MIT Imports: 6 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func DirEmpty

func DirEmpty(dir string) (is_empty bool)

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

func DirExists(dir string) (exists bool)

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

func DirSize(path string) (size int64, err error)

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

func DirsAdd(baseDir string, dirs []string)

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

func IsEmpty(dir string) bool

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

func List(dir string, only_dirs bool) (files []string)

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

func ShowTestResult(got, want any, t *testing.T)

ShowTestResult compares the expected and actual results, printing an error message if they differ.

func ShowTestResultDeepEqual

func ShowTestResultDeepEqual(got, want any, t *testing.T)

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

func (clean *Clean) FileDelete() error

FileDelete deletes the SourceFile from the system.

func (*Clean) FileTransfer

func (clean *Clean) FileTransfer() error

FileTransfer moves a file from SourceFile to TargetFile.

type Dir

type Dir struct {
	OS string
}

func (*Dir) GetDesktop

func (dir *Dir) GetDesktop() (desktop string)

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

func (dir *Dir) GetDownloads() (downloads string)

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

func (dir *Dir) GetTrash() (trash string)

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.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL