Help us shape the future of Go! Take the 2026 Go Developer Survey

fs

package
v0.10.2 Latest Latest
Warning

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

Go to latest
Published: Dec 10, 2023 License: Apache-2.0 Imports: 8 Imported by: 7

Documentation

Overview

Package fs provides a file system interface.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type File

type File interface {
	io.Closer
	io.Reader
	io.ReaderAt
	io.Seeker
	io.Writer
	io.WriterAt

	// Stat returns os.FileInfo describing the file.
	Stat() (os.FileInfo, error)

	// Sync commits the current contents of the file.
	Sync() error

	// Truncate changes the size of the file.
	Truncate(size int64) error

	// Slice reads and returns the contents of file from offset start to offset end.
	Slice(start int64, end int64) ([]byte, error)
}

File is the interface compatible with os.File.

type FileSystem

type FileSystem interface {
	// OpenFile opens the file with specified flag.
	OpenFile(name string, flag int, perm os.FileMode) (File, error)

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

	// Remove removes the file.
	Remove(name string) error

	// Rename renames oldpath to newpath.
	Rename(oldpath, newpath string) error

	// ReadDir reads the directory and returns a list of directory entries.
	ReadDir(name string) ([]os.FileInfo, error)

	// CreateLockFile creates a lock file.
	CreateLockFile(name string, perm os.FileMode) (LockFile, bool, error)
}

FileSystem represents a file system.

var Mem FileSystem = &memFS{files: map[string]*memFile{}}

Mem is a file system backed by memory.

var OS FileSystem = &osFS{}

OS is a file system backed by the os package.

var OSMMap FileSystem = &osMMapFS{}

OSMMap is a file system backed by the os package and memory-mapped files.

func Sub added in v0.10.1

func Sub(fsys FileSystem, dir string) FileSystem

Sub returns a new file system rooted at dir.

type LockFile

type LockFile interface {
	// Unlock and removes the lock file.
	Unlock() error
}

LockFile represents a lock file.

Jump to

Keyboard shortcuts

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