Documentation
¶
Index ¶
- Constants
- func DirsIdentical(dir1, dir2 string) (bool, error)
- func FilesIdentical(file1, file2 string) (bool, error)
- func FindFiles(root string, extension string) ([]string, error)
- func FindFilesWithFilter(root string, filterFn func(fs.FileInfo) bool) ([]string, error)
- func FormatFileSize(size int64) string
- func GetDirectorySize(path string) (int64, error)
- type ByteSize
- type FileMetadata
Constants ¶
const ( KB ByteSize = 1024 MB = KB * 1024 GB = MB * 1024 TB = GB * 1024 )
Variables ¶
This section is empty.
Functions ¶
func DirsIdentical ¶
DirsIdentical compares two directories to determine if they are identical It returns true if both directories contain the same files with identical content, and false otherwise
func FilesIdentical ¶
FilesIdentical compares two files byte by byte to determine if they are identical
func FindFiles ¶
FindFiles searches for files with the specified extension in the given root directory and returns a slice of matching file paths.
func FindFilesWithFilter ¶ added in v1.15.0
FindFilesWithFilter searches for files in the given root directory using a custom filter function. The filterFn parameter allows you to define arbitrary logic for file selection (e.g., size, mod time, type). If filterFn is nil, all non-directory, non-symlink files are returned.
func FormatFileSize ¶
FormatFileSize formats a file size given in bytes into a human-readable string with appropriate units (B, KB, MB, GB, TB).
func GetDirectorySize ¶
GetDirectorySize calculates the total size (in bytes) of all files within the specified directory
Types ¶
type FileMetadata ¶ added in v1.3.0
type FileMetadata struct {
Name string `json:"name"`
Size int64 `json:"size"`
IsDir bool `json:"is_dir"`
ModTime time.Time `json:"mod_time"`
Mode os.FileMode `json:"mode"`
Path string `json:"path"`
Ext string `json:"ext"`
Owner string `json:"owner"`
}
func GetFileMetadata ¶ added in v1.3.0
func GetFileMetadata(filePath string) (FileMetadata, error)
GetFileMetadata retrieves metadata for the specified file path. It returns a FileMetadata struct containing details about the file.