scanner

package
v0.0.0-...-bb9d0af Latest Latest
Warning

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

Go to latest
Published: Sep 27, 2018 License: MIT Imports: 5 Imported by: 1

Documentation

Overview

Package scanner will scan for files, and send the fileinfo onto a channel for DB insertion

Index

Constants

This section is empty.

Variables

View Source
var (
	// FileTypeFile is a regular file
	FileTypeFile = FileType("FILE")
	// FileTypeSymLink is a symbolic link
	FileTypeSymLink = FileType("SYMLINK")
	// FileTypeDirectory is a regular directory
	FileTypeDirectory = FileType("DIRECTORY")
	// FileTypeArchive is an archive
	FileTypeArchive = FileType("ARCHIVE")
	// FileTypeDevice is a Device File
	FileTypeDevice = FileType("DEVICE")
	// FileTypeOther are Named Pipes, etc -- other non regular files
	FileTypeOther = FileType("OTHER")
)

Functions

This section is empty.

Types

type FileFeed

type FileFeed chan *ScannedObject

FileFeed is returned from Scan, and can be read to receive scanned objects.

type FileType

type FileType string

FileType holds our file type

type ScannedObject

type ScannedObject struct {
	Error        error // If this is set, then there was an error, and the scanner is likely dead
	Path         string
	FileInfo     os.FileInfo
	FileType     FileType         // DIR, FILE, ARCHIVE
	ArchiveError error            // If set, something is wrong with archive
	Children     []*ScannedObject // Holds children of an archive
}

ScannedObject holds information about a file or archive

func (*ScannedObject) Dump

func (so *ScannedObject) Dump(verbose bool)

Dump displays the scanned object to stdout

func (*ScannedObject) SetFileType

func (so *ScannedObject) SetFileType() error

SetFileType will set our type based on the file mode

type Scanner

type Scanner struct {
	RootPath string

	FollowSymlinks bool // If true, will follow symlinks
	OneFilesystem  bool // If true, will not jump filesystems
	// contains filtered or unexported fields
}

Scanner holds a scanner's state, etc

func New

func New(root string, db *db.DB) (*Scanner, error)

New allocates a new Scanner that can be used to populate the filesystem

func (*Scanner) Dump

func (s *Scanner) Dump(verbose bool)

Dump will dump out the scanned items, demonstrating usage of the scanner

func (*Scanner) Scan

func (s *Scanner) Scan() (FileFeed, error)

Scan will return a channel to read from to receive files as they're being scanned.

func (*Scanner) ScanInsert

func (s *Scanner) ScanInsert() error

ScanInsert will kick off a scan, and insert all records into the database

Jump to

Keyboard shortcuts

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