Documentation
¶
Overview ¶
package filemod makes it easier to handle file modification times.
It provides tools for comparing the modification timestamps of files and of groups of files.
Lists of files can be sorted by modification time, by file size and by path order.
Lists of files can be partitioned into files, directories, and absent items.
Index ¶
- Variables
- type Errors
- type FileMetaInfo
- func (file FileMetaInfo) Err() error
- func (file FileMetaInfo) Exists() bool
- func (file FileMetaInfo) IsDir() bool
- func (file FileMetaInfo) ModTime() time.Time
- func (file FileMetaInfo) Mode() os.FileMode
- func (file FileMetaInfo) Name() string
- func (file FileMetaInfo) Newer(other FileMetaInfo) FileMetaInfo
- func (file FileMetaInfo) NewerThan(other FileMetaInfo) bool
- func (file FileMetaInfo) Older(other FileMetaInfo) FileMetaInfo
- func (file FileMetaInfo) OlderThan(other FileMetaInfo) bool
- func (file FileMetaInfo) Path() string
- func (file FileMetaInfo) Refresh() FileMetaInfo
- func (file FileMetaInfo) Size() int64
- func (file FileMetaInfo) Sys() interface{}
- type Files
- func (files Files) AbsentOnly() Files
- func (files Files) AllAreNewerThan(other Files) bool
- func (files Files) AllAreOlderThan(other Files) bool
- func (files Files) DirectoriesOnly() Files
- func (files Files) Errors() Errors
- func (files Files) FilesOnly() Files
- func (files Files) Filter(p func(info FileMetaInfo) bool) Files
- func (files Files) First() *FileMetaInfo
- func (files Files) Last() *FileMetaInfo
- func (files Files) OverlapsWith(other Files) bool
- func (files Files) Partition() (allFiles, allDirs, absent Files)
- func (files Files) PresentOnly() Files
- func (files Files) SortedByModTime() Files
- func (files Files) SortedByPath() Files
- func (files Files) SortedBySize() Files
Constants ¶
This section is empty.
Variables ¶
var Debug = func(message string, args ...interface{}) {}
Debug is a function that prints trace information. By default it does nothing; set it to (e.g.) 'fmt.Printf' to enable messages.
Functions ¶
This section is empty.
Types ¶
type FileMetaInfo ¶
type FileMetaInfo struct {
// contains filtered or unexported fields
}
FileMetaInfo holds information about one file (which may not exist).
func Lstat ¶ added in v0.7.0
func Lstat(path string) FileMetaInfo
Lstat tests a file path using the operating system. If the file is a symbolic link, the returned FileInfo describes the symbolic link. Lstat makes no attempt to follow the link.
func (FileMetaInfo) Err ¶
func (file FileMetaInfo) Err() error
Err gets the error, if any, from Stat. If there is an error, it will be of type *os.PathError.
func (FileMetaInfo) IsDir ¶
func (file FileMetaInfo) IsDir() bool
func (FileMetaInfo) ModTime ¶
func (file FileMetaInfo) ModTime() time.Time
func (FileMetaInfo) Mode ¶
func (file FileMetaInfo) Mode() os.FileMode
func (FileMetaInfo) Name ¶
func (file FileMetaInfo) Name() string
func (FileMetaInfo) Newer ¶ added in v0.6.0
func (file FileMetaInfo) Newer(other FileMetaInfo) FileMetaInfo
Newer compares the modification timestamps and returns the file that is newer.
func (FileMetaInfo) NewerThan ¶ added in v0.6.0
func (file FileMetaInfo) NewerThan(other FileMetaInfo) bool
NewerThan compares the modification timestamps and returns true if this file is newer than the other.
func (FileMetaInfo) Older ¶
func (file FileMetaInfo) Older(other FileMetaInfo) FileMetaInfo
Older compares the modification timestamps and returns the file that is older.
func (FileMetaInfo) OlderThan ¶ added in v0.6.0
func (file FileMetaInfo) OlderThan(other FileMetaInfo) bool
OlderThan compares the modification timestamps and returns true if this file is older than the other.
func (FileMetaInfo) Refresh ¶ added in v0.7.0
func (file FileMetaInfo) Refresh() FileMetaInfo
Refresh queries the operating system for the status of the file again. A new FileMetaInfo is returned that contains the current status of the file.
func (FileMetaInfo) Size ¶
func (file FileMetaInfo) Size() int64
func (FileMetaInfo) Sys ¶
func (file FileMetaInfo) Sys() interface{}
type Files ¶
type Files []FileMetaInfo
Files holds data on a group of files. Use the builtin 'append' if required; also use slicing as required.
func New ¶
New builds file information for one or more files. If filesystem errors arise, these are held in the files returned and can be inspected later.
func Of ¶ added in v0.6.0
func Of(files ...FileMetaInfo) Files
Of simply constructs a list of files. This is a convenience function.
func (Files) AbsentOnly ¶ added in v0.8.0
AbsentOnly returns only those files/directories that don't exist.
func (Files) AllAreNewerThan ¶ added in v0.6.0
AllAreNewerThan compares the file modification timestamps of two lists of files, returning true if all of 'files' are newer than all of 'other'.
func (Files) AllAreOlderThan ¶ added in v0.6.0
AllAreOlderThan compares the file modification timestamps of two lists of files, returning true if all of 'files' are older than all of 'other'.
func (Files) DirectoriesOnly ¶ added in v0.8.0
DirectoriesOnly returns only directories that exist.
func (Files) FilesOnly ¶ added in v0.8.0
FilesOnly returns only files that exist (i.e. not directories).
func (Files) Filter ¶ added in v0.8.0
func (files Files) Filter(p func(info FileMetaInfo) bool) Files
Filter returns only those items for which a predicate p returns true.
func (Files) First ¶ added in v0.9.0
func (files Files) First() *FileMetaInfo
First returns the first file, equivalent to files[0] with a check for an empty slice.
func (Files) Last ¶ added in v0.9.0
func (files Files) Last() *FileMetaInfo
Last returns the last file, equivalent to files[n-1] with a check for an empty slice.
func (Files) OverlapsWith ¶ added in v0.6.0
OverlapsWith compares the file modification timestamps of two lists of files, returning true if the range of modification times of 'files' overlaps with the range of modification times of the 'other' list.
func (Files) Partition ¶
Partition separates files and directories that exist from those that don't.
func (Files) PresentOnly ¶ added in v0.8.0
PresentOnly returns only those files/directories that exist.
func (Files) SortedByModTime ¶ added in v0.6.0
SortedByModTime rearranges the files into modification-time order with the oldest first. It returns the modified list.
func (Files) SortedByPath ¶ added in v0.6.0
SortedByPath rearranges the files into path order, similar to comparing pairs of strings. It returns the modified list.
func (Files) SortedBySize ¶ added in v0.6.0
SortedBySize rearranges the files into size order. It returns the modified list.