files

package
v0.21.18 Latest Latest
Warning

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

Go to latest
Published: Oct 13, 2021 License: GPL-3.0 Imports: 5 Imported by: 1

Documentation

Index

Constants

View Source
const (
	FileModeOnlyRead  os.FileMode = 0444
	FileModeReadWrite os.FileMode = 0666
)

FileMode

View Source
const (
	DefaultReadBufferLength = 1024
)

DefaultReadBufferLength default reader buffer length

Variables

This section is empty.

Functions

This section is empty.

Types

type FileInfo added in v0.21.13

type FileInfo struct {
	sync.Mutex
	*os.File
}

type FileRepo

type FileRepo interface {
	Open(file string) (*FileInfo, error)
	OpenFile(file string, flag int, perm os.FileMode) (*FileInfo, error)
	// judge if file is opening
	FileOpened(string) bool
	// get information with file name
	FileInfo(name string) (os.FileInfo, error)
	// close the file
	Close(file string) error
	// close all files which were opened
	CloseAll() error
	// read file
	Read(string) (b []byte, n int, err error)
	// rewrite file with context
	Write(name, context string, opts ...WriteOption) (int, error)
	WriteBytes(name string, b []byte, opts ...WriteOption) (int, error)
	// append context to the file
	WriteAppend(name, context string, opts ...WriteOption) (int, error)
	WriteAppendBytes(name string, b []byte, opts ...WriteOption) (int, error)
	// rename file
	Rename(oldpath, newpath string) error
	// set length of buffer to read file, default: 1024
	SetReadBufLength(int64) error
}

FileRepo execute file functions

func New

func New(opts ...Option) FileRepo

New return filerepo with default executor

func NewFileRepo added in v0.21.16

func NewFileRepo(opts ...Option) FileRepo

NewFileRepo return an new constraction of FileRepo

type Option added in v0.21.13

type Option func(*Options)

func ConcurrencyRead added in v0.21.17

func ConcurrencyRead() Option

func ReadBufferLength

func ReadBufferLength(rbuf int64) Option

type Options added in v0.21.13

type Options struct {
	ReadBufferLength int64
	ConcurrencyRead  bool
}

type WriteOption added in v0.21.13

type WriteOption func(*WriteOptions)

func WriteFlag added in v0.21.13

func WriteFlag(flag int) WriteOption

type WriteOptions added in v0.21.13

type WriteOptions struct {
	Flag *int
}

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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