parse

package
v1.0.1 Latest Latest
Warning

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

Go to latest
Published: Mar 25, 2022 License: MIT Imports: 15 Imported by: 0

Documentation

Overview

© Ben Garrett https://github.com/bengarrett/dupers

Index

Examples

Constants

This section is empty.

Variables

This section is empty.

Functions

func Contains

func Contains(find string, s ...string) bool

Contains returns true if find exists in s.

func Executable

func Executable(root string) bool

Executable returns true if the root directory contains an MS-DOS or Windows program file.

func Marker

func Marker(file database.Filepath, term string, exact bool) string

func Print

func Print(quiet, exact bool, term string, m *database.Matches) string

Print the results of the database comparisons.

Example
package main

import (
	"fmt"

	"github.com/bengarrett/dupers/database"
	"github.com/bengarrett/dupers/dupe/internal/parse"
	"github.com/gookit/color"
)

const (
	bucket1 = "../test/bucket1"
	file1   = "../../../test/bucket1/0vlLaUEvzAWP"
)

func main() {
	color.Enable = false
	matches := database.Matches{}
	matches[database.Filepath(file1)] = database.Bucket(bucket1)
	s := parse.Print(true, true, "", &matches)
	fmt.Print(s)
}
Output:

../../../test/bucket1/0vlLaUEvzAWP

Types

type Bucket

type Bucket string

type Checksum

type Checksum [32]byte

func Read

func Read(name string) (Checksum, error)

Read the named file to return a SHA256 checksum of it's data.

type Checksums

type Checksums map[Checksum]string

type Parser

type Parser struct {
	DB      *bolt.DB  // Bolt database.
	Buckets []Bucket  // Buckets to lookup.
	Compare Checksums // Compare hashes fetched from the database or file system.
	Files   int       // Files count.
	Sources []string  // Sources are directories or files to compare.
	Source  string    // Source directory or file to compare.
	// contains filtered or unexported fields
}

func (*Parser) All

func (p *Parser) All() []Bucket

All buckets returned as a slice.

func (*Parser) Compares

func (p *Parser) Compares() int

Compares the number of items contained in c.compare.

func (*Parser) OpenRead

func (p *Parser) OpenRead()

OpenRead opens the Bolt database for reading.

func (*Parser) OpenWrite

func (p *Parser) OpenWrite()

OpenWrite opens the Bolt database for reading and writing.

func (*Parser) PrintBuckets

func (p *Parser) PrintBuckets() string

PrintBuckets returns a list of buckets used by the database.

func (*Parser) SetBucket

func (p *Parser) SetBucket(names ...string)

SetBuckets adds the bucket name to a list of buckets.

func (*Parser) SetBuckets

func (p *Parser) SetBuckets() error

SetBuckets sets all the database buckets for use with the dupe or search commands.

func (*Parser) SetCompares

func (p *Parser) SetCompares(name Bucket) (int, error)

SetCompares fetches items from the named bucket and sets them to c.compare.

func (*Parser) SetTimer

func (p *Parser) SetTimer()

SetTimer starts a process timer.

func (*Parser) SetToCheck

func (p *Parser) SetToCheck(name string)

SetToCheck sets the named string as the directory or file to check.

func (*Parser) Timer

func (p *Parser) Timer() time.Duration

Timer returns the time taken since the process timer was instigated.

func (*Parser) ToCheck

func (p *Parser) ToCheck() string

ToCheck returns the directory or file to check.

Jump to

Keyboard shortcuts

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