files

package
v0.0.0-...-987fb27 Latest Latest
Warning

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

Go to latest
Published: Dec 24, 2021 License: GPL-3.0 Imports: 5 Imported by: 0

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

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)
	// FileOpened judge if file is opening
	FileOpened(string) bool
	// FileInfo get information with file name
	FileInfo(name string) (os.FileInfo, error)
	// Close close the file
	Close(file string) error
	// CloseAll close all files which were opened
	CloseAll() error
	// Read file
	Read(string) (b []byte, n int, err error)
	// Write rewrite file with context
	Write(name, context string, opts ...WriteOption) (int, error)
	WriteBytes(name string, b []byte, opts ...WriteOption) (int, error)
	// WriteAppend append context to the file
	WriteAppend(name, context string, opts ...WriteOption) (int, error)
	WriteAppendBytes(name string, b []byte, opts ...WriteOption) (int, error)
	// Rename rename file
	Rename(oldPath, newPath string) error
	// SetReadBufLength 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

func NewFileRepo(opts ...Option) FileRepo

NewFileRepo return an new constraction of FileRepo

type Option

type Option func(*Options)

func ConcurrencyRead

func ConcurrencyRead() Option

func ReadBufferLength

func ReadBufferLength(rbuf int64) Option

type Options

type Options struct {
	ReadBufferLength int64
	ConcurrencyRead  bool
}

type WriteOption

type WriteOption func(*WriteOptions)

func WriteFlag

func WriteFlag(flag int) WriteOption

type WriteOptions

type WriteOptions struct {
	Flag *int
}

Jump to

Keyboard shortcuts

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