utils

package
v1.1.0 Latest Latest
Warning

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

Go to latest
Published: Apr 14, 2020 License: Apache-2.0 Imports: 13 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CheckFolder

func CheckFolder(path string) bool

CheckFolder checks whether a given directory exists or not

func CommandAvailable

func CommandAvailable(command string) bool

CommandAvailable checks whether a command is available or not

func Contains added in v1.1.0

func Contains(slice []string, str string) bool

Contains checks if a string slice contains a string

func CopyFile

func CopyFile(sourcePath, destinationPath string) error

CopyFile copies a file from source to destination

func GetFileHash added in v1.1.0

func GetFileHash(path string, hashFiles chan<- File, errorFiles chan<- File)

GetFileHash returns the hash sum for a file

func GetFilesWithHash added in v1.1.0

func GetFilesWithHash(sourcePath string, hashFiles chan<- File, errorFiles chan<- File, fileCount chan<- int) error

GetFilesWithHash recursively scans all files in a directory and calculates its hash sum

func PrintBanner

func PrintBanner()

PrintBanner prints the banner for sort-it

func PrintMessage

func PrintMessage(message, mode string)

PrintMessage prints a message

func WriteErrorFiles

func WriteErrorFiles(destinationFolder string, errors []File)

WriteErrorFiles

func WriteFileLogs added in v1.1.0

func WriteFileLogs(destinationFolder string, sortedFiles, duplicateFiles []File)

WriteFileLogs creates html/json files for file logs

Types

type File

type File struct {
	Path         string `json:"path,omitempty"`
	RelativePath string `json:"relative_path,omitempty"`
	Hash         string `json:"hash,omitempty"`
	Error        string `json:"error,omitempty"`
	Duplicates   []File `json:"duplicates,omitempty"`
}

File represents a scanned file

func GetDuplicates added in v1.1.0

func GetDuplicates(files []File, hash string) []File

GetDuplicates returns all duplicates for a given hash

type MetaFile added in v1.1.0

type MetaFile struct {
	SourceFile        string `json:"SourceFile"`
	FileName          string `json:"FileName"`
	Directory         string `json:"Directory"`
	FileSize          string `json:"FileSize"`
	FileType          string `json:"FileType"`
	FileTypeExtension string `json:"FileTypeExtension"`
	MIMEType          string `json:"MIMEType"`
	CreateDate        string `json:"CreateDate"`
	Album             string `json:"Album"`
	Artist            string `json:"Artist"`
	Title             string `json:"Title"`
}

MetaFile represents a file including only necessary meta data

func GetFileMetadata

func GetFileMetadata(path string) (MetaFile, error)

GetFileMetadata returns the metadata for a file

Jump to

Keyboard shortcuts

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