Documentation
¶
Overview ¶
Package fsutil provides methods for working with files on POSIX compatible systems
Package fsutil provides methods for working with files on POSIX compatible systems
Index ¶
- Variables
- func CheckPerms(props, path string) bool
- func CopyDir(from, to string) error
- func CopyFile(from, to string, perms ...os.FileMode) error
- func GetATime(path string) (time.Time, error)
- func GetCTime(path string) (time.Time, error)
- func GetMTime(path string) (time.Time, error)
- func GetMode(path string) os.FileMode
- func GetOwner(path string) (int, int, error)
- func GetSize(path string) int64
- func GetTimes(path string) (time.Time, time.Time, time.Time, error)
- func GetTimestamps(path string) (int64, int64, int64, error)
- func IsBlockDevice(path string) bool
- func IsCharacterDevice(path string) bool
- func IsDir(path string) bool
- func IsEmptyDir(path string) bool
- func IsExecutable(path string) bool
- func IsExecutableByUser(path, userName string) bool
- func IsExist(path string) bool
- func IsLink(path string) bool
- func IsNonEmpty(path string) bool
- func IsReadable(path string) bool
- func IsReadableByUser(path, userName string) bool
- func IsRegular(path string) bool
- func IsSocket(path string) bool
- func IsWritable(path string) bool
- func IsWritableByUser(path, userName string) bool
- func LineCount(file string) int
- func List(dir string, ignoreHidden bool, filters ...ListingFilter) []string
- func ListAll(dir string, ignoreHidden bool, filters ...ListingFilter) []string
- func ListAllDirs(dir string, ignoreHidden bool, filters ...ListingFilter) []string
- func ListAllFiles(dir string, ignoreHidden bool, filters ...ListingFilter) []string
- func ListToAbsolute(path string, list []string)
- func MoveFile(from, to string, perms ...os.FileMode) error
- func Pop() string
- func ProperPath(props string, paths []string) string
- func Push(dir string) string
- func ValidatePerms(props, path string) error
- type ListingFilter
Constants ¶
This section is empty.
Variables ¶
var ErrEmptyPath = errors.New("Path is empty")
ErrEmptyPath can be returned by different methods if given path is empty and can't be used
Functions ¶
func CheckPerms ¶
CheckPerms checks many props at once
F - is file D - is directory X - is executable L - is link W - is writable R - is readable B - is block device C - is character device S - not empty (only for files)
func GetTimestamps ¶
GetTimestamps returns time of access, modification, and creation at once as unix timestamp
func IsBlockDevice ¶
IsBlockDevice returns true if the given object is a device
func IsCharacterDevice ¶
IsCharacterDevice returns true if the given object is a character device
func IsEmptyDir ¶
IsEmptyDir returns true if given directory es empty
func IsExecutable ¶
IsExecutable returns true if given object is executable by current user
func IsExecutableByUser ¶
IsExecutableByUser returns true if given object is executable by some user
func IsNonEmpty ¶
IsNonEmpty returns true if given file is not empty
func IsReadable ¶
IsReadable returns true if given object is readable by current user
func IsReadableByUser ¶
IsReadableByUser returns true if given object is readable by some user
func IsWritable ¶
IsWritable returns true if given object is writable by current user
func IsWritableByUser ¶
IsWritableByUser returns true if given object is writable by some user
func List ¶
func List(dir string, ignoreHidden bool, filters ...ListingFilter) []string
List is lightweight method for listing directory
func ListAll ¶
func ListAll(dir string, ignoreHidden bool, filters ...ListingFilter) []string
ListAll is lightweight method for listing all files and directories
func ListAllDirs ¶
func ListAllDirs(dir string, ignoreHidden bool, filters ...ListingFilter) []string
ListAllDirs is lightweight method for listing all directories
func ListAllFiles ¶
func ListAllFiles(dir string, ignoreHidden bool, filters ...ListingFilter) []string
ListAllFiles is lightweight method for listing all files
func ListToAbsolute ¶
ListToAbsolute converts slice with relative paths to slice with absolute paths
func ProperPath ¶
ProperPath returns the first proper path from a given slice
func ValidatePerms ¶
ValidatePerms validates permissions for file or directory
Types ¶
type ListingFilter ¶
type ListingFilter struct { MatchPatterns []string // Slice with shell file name patterns NotMatchPatterns []string // Slice with shell file name patterns ATimeOlder int64 // Files with ATime less or equal to defined timestamp (BEFORE date) ATimeYounger int64 // Files with ATime greater or equal to defined timestamp (AFTER date) CTimeOlder int64 // Files with CTime less or equal to defined timestamp (BEFORE date) CTimeYounger int64 // Files with CTime greater or equal to defined timestamp (AFTER date) MTimeOlder int64 // Files with MTime less or equal to defined timestamp (BEFORE date) MTimeYounger int64 // Files with MTime greater or equal to defined timestamp (AFTER date) SizeLess int64 // Files with size less than defined SizeGreater int64 // Files with size greater than defined SizeEqual int64 // Files with size equals than defined SizeZero bool // Empty files Perms string // Permission (see fsutil.CheckPerms for more info) NotPerms string // Permission (see fsutil.CheckPerms for more info) }
ListingFilter is struct with properties for filtering listing output