files

package module
v0.0.0-...-9730fb6 Latest Latest
Warning

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

Go to latest
Published: Apr 8, 2020 License: GPL-3.0 Imports: 4 Imported by: 2 modules, 1 package

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

README

files

Archive... move files into github.com/go-trellis/common

a tool in go to execute file

Introduction

Installation
	go get -u github.com/go-trellis/files
Usage
// FileRepo execute file functions
type FileRepo interface {
	// judge if file is opening
	FileOpened(string) bool
	// read file
	Read(string) (b []byte, n int, err error)
	// rewrite file with context
	Write(name, context string) (int, error)
	WriteBytes(name string, b []byte) (int, error)
	// append context to the file
	WriteAppend(name, context string) (int, error)
	WriteAppendBytes(name string, b []byte) (int, error)
	// rename file
	Rename(oldpath, newpath string) error
	// set length of buffer to read file, default: 1024
	SetReadBufLength(int) error
	// get information with file name
	FileInfo(name string) (os.FileInfo, error)
}
Sample

Documentation

Index

Constants

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

FileMode

View Source
const (
	ReadBufferLength = 1024
)

ReadBufferLength default reader buffer length

Variables

View Source
var (
	ErrFileIsAlreadyOpen = errors.New("file is already open")
	ErrFailedReadFile    = errors.New("failed read file")

	ErrReadBufferLengthBelowZero = errors.New("read buffer must above zero")
)

errors

Functions

This section is empty.

Types

type FileRepo

type FileRepo interface {
	// judge if file is opening
	FileOpened(string) bool
	// read file
	Read(string) (b []byte, n int, err error)
	// rewrite file with context
	Write(name, context string) (int, error)
	WriteBytes(name string, b []byte) (int, error)
	// append context to the file
	WriteAppend(name, context string) (int, error)
	WriteAppendBytes(name string, b []byte) (int, error)
	// rename file
	Rename(oldpath, newpath string) error
	// set length of buffer to read file, default: 1024
	SetReadBufLength(int) error
	// get information with file name
	FileInfo(name string) (os.FileInfo, error)
}

FileRepo execute file functions

func New

func New() FileRepo

New return filerepo with default executor

type FileStatus

type FileStatus int

FileStatus defile file status

const (
	// nothing
	FileStatusClosed FileStatus = iota
	// file is opened
	FileStatusOpening
	// file is moving or rename
	FileStatusMoving
)

file status

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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