fileops

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Sep 27, 2022 License: Apache-2.0 Imports: 14 Imported by: 1

Documentation

Overview

nolint

Index

Constants

This section is empty.

Variables

View Source
var (
	IO_PRIORITY_ULTRA_HIGH = 0
	IO_PRIORITY_HIGH       = 1
	IO_PRIORITY_NORMAL     = 2
	IO_PRIORITY_LOW        = 3
)

Functions

func CopyFile

func CopyFile(srcFile, dstFile string, opt ...FSOption) (written int64, err error)

CopyFile copys file content from srcFile to dstFile until either EOF is reached on srcFile or an errors accurs. the optional opt is: (FileLockOption,FilePriorityOption)

func CreateTime

func CreateTime(name string) (*time.Time, error)

func Glob

func Glob(pattern string) ([]string, error)

Glob returns the names of all files matching pattern or nil if there is no matching file.

func MUnmap

func MUnmap(data []byte) error

func Mkdir

func Mkdir(path string, perm os.FileMode, opt ...FSOption) error

Mkdir creates a directory named path, it's parents directory must exist. the optional opt is: FileLockOption

func MkdirAll

func MkdirAll(path string, perm os.FileMode, opt ...FSOption) error

MkdirAll creates a directory named path, along with any necessary parents the optional opt is: FileLockOption

func Mmap

func Mmap(fd uintptr, size int) (data []byte, err error)

func ReadDir

func ReadDir(dirname string) ([]os.FileInfo, error)

ReadDir reads the directory named by dirname and returns a list of fs.FileInfo for the directory's contents, sorted by filename.

func ReadFile

func ReadFile(filename string, opt ...FSOption) ([]byte, error)

ReadFile reads the file named by filename and returns the contents. the optional opt is: FilePriorityOption

func Remove

func Remove(name string, opt ...FSOption) error

Remove removes the named file or (empty) directory. the optional opt is: FileLockOption

func RemoveAll

func RemoveAll(path string, opt ...FSOption) error

RemoveAll removes path and any children it contains. the optional opt is: FileLockOption

func RenameFile

func RenameFile(oldPath, newPath string, opt ...FSOption) error

RenameFile renames (moves) oldPath to newPath. If newPath already exists and is not a directory, Rename replaces it. the optional opt is: FileLockOption

func Stat

func Stat(name string) (os.FileInfo, error)

Stat returns a FileInfo describing the named file.

func Truncate

func Truncate(name string, size int64) error

func WriteFile

func WriteFile(filename string, data []byte, perm os.FileMode, opt ...FSOption) error

WriteFile writes data to a file named by filename. If the file does not exist, WriteFile creates it with permissions perm the optional opt is: (FileLockOption,FilePriorityOption)

Types

type FSOption

type FSOption interface {
	Parameter() interface{}
}

type File

type File interface {
	io.Closer
	io.Reader
	io.Seeker
	io.Writer
	io.ReaderAt
	Name() string
	Truncate(size int64) error
	Sync() error
	Stat() (os.FileInfo, error)
	SyncUpdateLength() error
	Fd() uintptr
}

func Create

func Create(name string, opt ...FSOption) (File, error)

Create creates or truncates the named file. If the file already exists, it is truncated. If the file does not exist, it is created with mode 0666 the optional opt is: (FileLockOption,FilePriorityOption)

func Open

func Open(name string, opt ...FSOption) (File, error)

Open opens the named file with specified options. the optional opt is: (FileLockOption,FilePriorityOption)

func OpenFile

func OpenFile(name string, flag int, perm os.FileMode, opt ...FSOption) (File, error)

OpenFile opens the named file with specified flag and other options. the optional opt is: (FileLockOption,FilePriorityOption)

type FileLockOption

type FileLockOption string

func (FileLockOption) Parameter

func (opt FileLockOption) Parameter() interface{}

type FilePriorityOption

type FilePriorityOption int

func (FilePriorityOption) Parameter

func (opt FilePriorityOption) Parameter() interface{}

type VFS

type VFS interface {
	// Open opens the named file with specified options.
	// the optional opt is: (FileLockOption,FilePriorityOption)
	Open(name string, opt ...FSOption) (File, error)
	// OpenFile opens the named file with specified flag and other options.
	// the optional opt is: (FileLockOption,FilePriorityOption)
	OpenFile(name string, flag int, perm os.FileMode, opt ...FSOption) (File, error)
	// Create creates or truncates the named file. If the file already exists, it is truncated.
	// If the file does not exist, it is created with mode 0666
	// the optional opt is: (FileLockOption,FilePriorityOption)
	Create(name string, opt ...FSOption) (File, error)

	// Remove removes the named file or (empty) directory.
	// the optional opt is: FileLockOption
	Remove(name string, opt ...FSOption) error
	// RemoveAll removes path and any children it contains.
	// the optional opt is: FileLockOption
	RemoveAll(path string, opt ...FSOption) error
	// Mkdir creates a directory named path, it's parents directory must exist.
	// the optional opt is: FileLockOption
	Mkdir(path string, perm os.FileMode, opt ...FSOption) error
	// MkdirAll creates a directory named path, along with any necessary parents
	// the optional opt is: FileLockOption
	MkdirAll(path string, perm os.FileMode, opt ...FSOption) error
	// ReadDir reads the directory named by dirname and returns
	// a list of fs.FileInfo for the directory's contents, sorted by filename.
	ReadDir(dirname string) ([]os.FileInfo, error)
	// Glob returns the names of all files matching pattern or nil if there is no matching file.
	Glob(pattern string) ([]string, error)
	// RenameFile renames (moves) oldPath to newPath.
	// If newPath already exists and is not a directory, Rename replaces it.
	// the optional opt is: FileLockOption
	RenameFile(oldPath, newPath string, opt ...FSOption) error

	// Stat returns a FileInfo describing the named file.
	Stat(name string) (os.FileInfo, error)

	// WriteFile writes data to a file named by filename.
	// If the file does not exist, WriteFile creates it with permissions perm
	// the optional opt is: (FileLockOption,FilePriorityOption)
	WriteFile(filename string, data []byte, perm os.FileMode, opt ...FSOption) error
	// ReadFile reads the file named by filename and returns the contents.
	// the optional opt is: FilePriorityOption
	ReadFile(filename string, opt ...FSOption) ([]byte, error)
	// CopyFile copys file content from srcFile to dstFile until either EOF is reached on srcFile or an errors accurs.
	// the optional opt is: (FileLockOption,FilePriorityOption)
	CopyFile(srcFile, dstFile string, opt ...FSOption) (written int64, err error)

	CreateTime(name string) (*time.Time, error)

	// Truncate changes the size of the file to size.
	// the optional opt is: (FileLockOption)
	Truncate(name string, size int64, opt ...FSOption) error
}

func NewFS

func NewFS() VFS

Jump to

Keyboard shortcuts

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