fileutil

package
v0.25.2 Latest Latest
Warning

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

Go to latest
Published: Apr 5, 2024 License: Apache-2.0 Imports: 10 Imported by: 0

Documentation

Overview

Package fileutil provides file utility functions, complementing the lower level abstractions found in the standard library.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CopyFileUpTo added in v0.21.0

func CopyFileUpTo(dst io.Writer, fname string, maxBytes int64) error

CopyFileUpTo copies content of the file up to maxBytes it returns an error if file is larger than allowed maximum

func Getwd added in v0.2.0

func Getwd() string

Getwd returns a rooted path name corresponding to the current directory. If the current directory can be reached via multiple paths (due to symbolic links), Getwd may return any one of them.

On failure, will return "."

func IsReadableFile

func IsReadableFile(path string) (bool, error)

IsReadableFile reports whether the file exists and is readable. If the error is non-nil, it means there might be a file or directory with that name but we cannot read it.

Adapted from the upspin.io source code.

func ReadFileUpTo added in v0.21.0

func ReadFileUpTo(fname string, maxSize int64) ([]byte, error)

ReadFileUpTo reads file up to given size it returns an error if file is larger than allowed maximum

Types

type Watcher added in v0.12.2

type Watcher struct {
	*signal.Signal
	// contains filtered or unexported fields
}

A Watcher watches files for changes.

func NewWatcher added in v0.12.2

func NewWatcher() *Watcher

NewWatcher creates a new Watcher.

func (*Watcher) Watch added in v0.24.0

func (watcher *Watcher) Watch(ctx context.Context, filePaths []string)

Watch updates the watched file paths.

Jump to

Keyboard shortcuts

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