filesystem

package
v1.1.0 Latest Latest
Warning

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

Go to latest
Published: Apr 14, 2024 License: MIT Imports: 9 Imported by: 0

Documentation

Overview

Package filesystem is a collection of various different filesystem helper functions.

Index

Constants

View Source
const (
	CurrentDirectory  = "."
	PreviousDirectory = ".."
	HomeDirectory     = "~"
	RootDirectory     = "/"
)

Directory shortcuts.

View Source
const (
	DirectoriesListingType = "directories"
	FilesListingType       = "files"
)

Different types of listings.

Variables

This section is empty.

Functions

func ConvertBytesToSizeString added in v1.1.0

func ConvertBytesToSizeString(size int64) string

ConvertBytesToSizeString converts a byte count to a human readable string.

func CopyDirectory

func CopyDirectory(pathname string) error

CopyDirectory copies a directory given a path.

func CopyFile

func CopyFile(name string) error

CopyFile copies a file given a name.

func CreateDirectory

func CreateDirectory(name string) error

CreateDirectory creates a new directory given a name.

func CreateFile

func CreateFile(name string) error

CreateFile creates a file given a name.

func DeleteDirectory

func DeleteDirectory(name string) error

DeleteDirectory deletes a directory given a name.

func DeleteFile

func DeleteFile(name string) error

DeleteFile deletes a file given a name.

func FindFilesByName

func FindFilesByName(name, dir string) ([]string, []fs.DirEntry, error)

FindFilesByName returns files found based on a name.

func GetDirectoryItemSize

func GetDirectoryItemSize(path string) (int64, error)

GetDirectoryItemSize calculates the size of a directory or file.

func GetDirectoryListing

func GetDirectoryListing(dir string, showHidden bool) ([]fs.DirEntry, error)

GetDirectoryListing returns a list of files and directories within a given directory.

func GetDirectoryListingByType

func GetDirectoryListingByType(dir, listingType string, showHidden bool) ([]fs.DirEntry, error)

GetDirectoryListingByType returns a directory listing based on type (directories | files).

func GetHomeDirectory

func GetHomeDirectory() (string, error)

GetHomeDirectory returns the users home directory.

func GetWorkingDirectory

func GetWorkingDirectory() (string, error)

GetWorkingDirectory returns the current working directory.

func MoveDirectoryItem

func MoveDirectoryItem(src, dst string) error

MoveDirectoryItem moves a file from one place to another.

func ReadFileContent

func ReadFileContent(name string) (string, error)

ReadFileContent returns the contents of a file given a name.

func RenameDirectoryItem

func RenameDirectoryItem(src, dst string) error

RenameDirectoryItem renames a directory or files given a source and destination.

func Unzip

func Unzip(name string) error

Unzip unzips a directory given a name.

func WriteToFile

func WriteToFile(path, content string) error

WriteToFile writes content to a file, overwriting content if it exists.

func Zip

func Zip(name string) error

Zip zips a directory given a name.

Types

This section is empty.

Jump to

Keyboard shortcuts

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