fs

package
v0.9.3 Latest Latest
Warning

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

Go to latest
Published: Apr 24, 2024 License: Apache-2.0 Imports: 5 Imported by: 4

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func DeleteFile

func DeleteFile(path string) error

DeleteFile deletes a regular file. If not found or any other occurs, error is returned.

func FileSize added in v0.0.9

func FileSize(path string) (int64, error)

FileSize returns size of a provided file. In case of an error the function returns -1 and logs the error.

func GetFileMtime

func GetFileMtime(filePath string) (time.Time, error)

GetFileMtime returns a file modification time

func IsDir

func IsDir(path string) (bool, error)

IsDir tests whether a provided path represents a directory. If not, which means either the path does not exist at all or it is a non-directory path, false is returned along with nil error. Non-nil error should be expected only in case the function fails to obtain required info (e.g. due to permissions)

func IsFile

func IsFile(path string) (bool, error)

IsFile tests whether the file with a specified path is a regular file.

func PathExists added in v0.0.9

func PathExists(path string) bool

PathExists tests whether the provided path exists no matter what it is (file, dir, ...)

Types

type FileList added in v0.0.9

type FileList struct {
	// contains filtered or unexported fields
}

FileList is an abstraction for list of files along with their modification time information. It supports sorting.

func ListDirsInDir added in v0.0.9

func ListDirsInDir(path string, newestFirst bool) (FileList, error)

ListDirsInDir lists directories in a directory (without recursion).

func ListFilesInDir added in v0.0.9

func ListFilesInDir(path string, newestFirst bool) (FileList, error)

ListFilesInDir lists files according to their modification time (newest first).

func (*FileList) First added in v0.0.9

func (f *FileList) First() os.FileInfo

First returns an item with the latest modification time.

func (*FileList) ForEach added in v0.0.9

func (f *FileList) ForEach(fn func(info os.FileInfo, idx int) bool)

func (*FileList) Len added in v0.0.9

func (f *FileList) Len() int

func (*FileList) Less added in v0.0.9

func (f *FileList) Less(i, j int) bool

func (*FileList) Swap added in v0.0.9

func (f *FileList) Swap(i, j int)

Jump to

Keyboard shortcuts

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