checkfile

package module
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Aug 5, 2021 License: BSL-1.0 Imports: 3 Imported by: 1

README

checkfile

GoDoc Go Report Card

About

This package provides functions to check file status and content. It is published on https://github.com/vbsw/checkfile.

Copyright 2020, Vitali Baumtrok (vbsw@mailbox.org).

checkfile is distributed under the Boost Software License, version 1.0. (See accompanying file LICENSE or copy at http://www.boost.org/LICENSE_1_0.txt)

checkfile is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the Boost Software License for more details.

Using Git

Get the master branch and all refs of this project:

$ git clone https://github.com/vbsw/checkfile.git

See all tags:

$ git tag -l

See local and remote branches:

$ git branch -a

Checkout other branches than master, for example the development branch:

$ git branch development origin/development
$ git checkout development

See tracked remote branches:

$ git branch -vv

Update all tracked branches and all refs:

$ git fetch

References

Documentation

Overview

Package checkfile provides functions to check file status and content.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ContainsAll

func ContainsAll(path string, termsBuffer *TermsBuffer) (bool, error)

ContainsAll returns true, if the file exists and contains all of the search terms.

func ContainsAny

func ContainsAny(path string, termsBuffer *TermsBuffer) (bool, error)

ContainsAny returns true, if the file exists and contains at least one of the search terms.

func Exists

func Exists(path string) bool

Exists returns true, if the file exists. It doesn't matter if it's a directory or a file.

func IsDirectory

func IsDirectory(path string) bool

IsDirectory returns true, if the file exists and is a directory.

func IsFile

func IsFile(path string) bool

IsFile returns true, if the file exists and is a file.

func Size

func Size(path string) int64

Size returns the size of the file in bytes. If the file does not exist it returns 0.

Types

type TermsBuffer

type TermsBuffer struct {
	Buffer    []byte
	Terms     [][]byte
	MinLength int
	MaxLength int
	Unmatched []int
}

TermsBuffer holds a buffer for the file and the search terms.

func NewTermsBuffer

func NewTermsBuffer(bufferSize int, searchTerms []string) *TermsBuffer

NewTermsBuffer creates a new instance of TermsBuffer.

func NewTermsBufferFromBytes

func NewTermsBufferFromBytes(bufferSize int, searchTerms [][]byte) *TermsBuffer

NewTermsBufferFromBytes creates a new instance of TermsBuffer.

func (*TermsBuffer) SetTerms

func (termsBuffer *TermsBuffer) SetTerms(searchTerms []string)

SetTerms sets the search terms and the minimum and maximum term length. Empty search terms are removed.

func (*TermsBuffer) SetTermsFromBytes

func (termsBuffer *TermsBuffer) SetTermsFromBytes(searchTerms [][]byte)

SetTermsFromBytes sets the search terms and the minimum and maximum term length. Empty search terms are not removed.

Jump to

Keyboard shortcuts

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