fileutil

package
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: May 30, 2023 License: Apache-2.0 Imports: 11 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func DirExists

func DirExists(path string) (bool, error)

DirExists returns true if the given path exists and is a directory.

func EmptyDir

func EmptyDir(path string) error

EmptyDir will recursively remove the contents of a directory at the given path.

func EnsureDir

func EnsureDir(path string) error

EnsureDir will create a directory at the given path if it doesn't already exist.

func EnsureDirAll

func EnsureDirAll(path string) error

EnsureDirAll will create a directory at the given path along with any necessary parents if they don't already exist.

func FileExists

func FileExists(path string) (bool, error)

FileExists returns true if the given path exists.

func FileType

func FileType(filePath string) (types.Type, error)

FileType uses the filetype package to determine the given file path's type.

func GetHomeDirectory

func GetHomeDirectory() string

GetHomeDirectory returns the path of the user's home directory. ~ on Unix and C:\Users\UserName on Windows.

func GetIntraDir

func GetIntraDir(pattern string, depth, length int) string

GetIntraDir returns a string that can be added to filepath.Join to implement directory depth, "" on error eg given a pattern of 0af63ce3c99162e9df23a997f62621c5 and a depth of 2 length of 3 returns 0af/63c or 0af\63c ( dependin on os) that can be later used like this filepath.Join(directory, intradir, basename).

func GetParent

func GetParent(path string) *string

GetParent returns the parent directory of the given path.

func IsZipFileUncompressed

func IsZipFileUncompressed(path string) (bool, error)

IsZipFileUncompressed returns true if zip file in path is using 0 compression level.

func ListDir

func ListDir(path string) []string

ListDir will return the contents of a given directory path as a string slice.

func MatchEntries

func MatchEntries(dir, pattern string) ([]string, error)

MatchEntries returns a string slice of the entries in directory dir which match the regexp pattern. On error an empty slice is returned MatchEntries isn't recursive, only the specific 'dir' is searched without being expanded.

func RemoveDir

func RemoveDir(path string) error

RemoveDir removes the given dir (if it exists) along with all of its contents.

func SafeMove

func SafeMove(src, dst string) error

SafeMove move src to dst in safe mode.

func ServeFileNoCache

func ServeFileNoCache(w http.ResponseWriter, r *http.Request, filepath string)

ServeFileNoCache serves the provided file, ensuring that the response contains headers to prevent caching.

func Touch

func Touch(path string) error

Touch creates an empty file at the given path if it doesn't already exist.

func WriteFile

func WriteFile(path string, file []byte) error

WriteFile writes file to path creating parent directories if needed.

Types

This section is empty.

Jump to

Keyboard shortcuts

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