rofs

package module
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: Dec 12, 2025 License: MIT Imports: 4 Imported by: 0

README

rofs - Read Only FileSystem

Go Reference Go Report Card CI License

The rofs package wraps any other absfs FileSystem implementation and makes it read only.

Install

$ go get github.com/absfs/rofs

absfs

Check out the absfs repo for more information about the abstract FileSystem interface and features like FileSystem composition.

LICENSE

This project is governed by the MIT License. See LICENSE

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type File

type File struct {
	// contains filtered or unexported fields
}

func (*File) Close

func (f *File) Close() error

func (*File) Name

func (f *File) Name() string

func (*File) Read

func (f *File) Read(p []byte) (int, error)

func (*File) ReadAt

func (f *File) ReadAt(b []byte, off int64) (n int, err error)

func (*File) ReadDir

func (f *File) ReadDir(n int) ([]fs.DirEntry, error)

ReadDir reads the contents of the directory and returns a slice of up to n DirEntry values. This is a read operation, so it's allowed in read-only mode.

func (*File) Readdir

func (f *File) Readdir(n int) ([]os.FileInfo, error)

func (*File) Readdirnames

func (f *File) Readdirnames(n int) ([]string, error)

func (*File) Seek

func (f *File) Seek(offset int64, whence int) (ret int64, err error)

func (*File) Stat

func (f *File) Stat() (os.FileInfo, error)

func (*File) Sync

func (f *File) Sync() error

func (*File) Truncate

func (f *File) Truncate(size int64) error

func (*File) Write

func (f *File) Write(p []byte) (int, error)

func (*File) WriteAt

func (f *File) WriteAt(b []byte, off int64) (n int, err error)

func (*File) WriteString

func (f *File) WriteString(s string) (n int, err error)

type FileSystem

type FileSystem struct {
	// contains filtered or unexported fields
}

func NewFS

func (*FileSystem) Chdir

func (f *FileSystem) Chdir(dir string) error

func (*FileSystem) Chmod

func (f *FileSystem) Chmod(name string, mode os.FileMode) error

Chmod changes the mode of the named file to mode.

func (*FileSystem) Chown

func (f *FileSystem) Chown(name string, uid, gid int) error

Chown changes the owner and group ids of the named file

func (*FileSystem) Chtimes

func (f *FileSystem) Chtimes(name string, atime time.Time, mtime time.Time) error

Chtimes changes the access and modification times of the named file

func (*FileSystem) Create

func (f *FileSystem) Create(name string) (absfs.File, error)

func (*FileSystem) Getwd

func (f *FileSystem) Getwd() (dir string, err error)

func (*FileSystem) Lchown

func (f *FileSystem) Lchown(name string, uid, gid int) error

Lchown changes the numeric uid and gid of the named file. If the file is a symbolic link, it changes the uid and gid of the link itself. If there is an error, it will be of type *PathError.

On Windows, it always returns the syscall.EWINDOWS error, wrapped in `*PathError`.

func (*FileSystem) Lstat

func (f *FileSystem) Lstat(name string) (os.FileInfo, error)

Lstat returns a FileInfo describing the named file. If the file is a symbolic link, the returned FileInfo describes the symbolic link. Lstat makes no attempt to follow the link. If there is an error, it will be of type *PathError.

func (*FileSystem) Mkdir

func (f *FileSystem) Mkdir(name string, perm os.FileMode) error

Mkdir creates a directory in the filesystem, return an error if any happens.

func (*FileSystem) MkdirAll

func (f *FileSystem) MkdirAll(name string, perm os.FileMode) error

func (*FileSystem) Open

func (f *FileSystem) Open(name string) (absfs.File, error)

func (*FileSystem) OpenFile

func (f *FileSystem) OpenFile(name string, flag int, perm os.FileMode) (absfs.File, error)

OpenFile opens a file using the given flags and the given mode.

func (*FileSystem) ReadDir

func (f *FileSystem) ReadDir(name string) ([]fs.DirEntry, error)

ReadDir reads the named directory and returns a list of directory entries. This is a read operation, so it's allowed in read-only mode.

func (*FileSystem) ReadFile

func (f *FileSystem) ReadFile(name string) ([]byte, error)

ReadFile reads the named file and returns its contents. This is a read operation, so it's allowed in read-only mode.

func (f *FileSystem) Readlink(name string) (string, error)

Readlink returns the destination of the named symbolic link. If there is an error, it will be of type *PathError.

func (*FileSystem) Remove

func (f *FileSystem) Remove(name string) error

Remove removes a file identified by name, returning an error, if any happens.

func (*FileSystem) RemoveAll

func (f *FileSystem) RemoveAll(path string) (err error)

func (*FileSystem) Rename

func (f *FileSystem) Rename(oldpath, newpath string) error

Rename renames (moves) oldpath to newpath. If newpath already exists and is not a directory, Rename replaces it. OS-specific restrictions may apply when oldpath and newpath are in different directories. If there is an error, it will be of type *LinkError.

func (*FileSystem) Stat

func (f *FileSystem) Stat(name string) (os.FileInfo, error)

Stat returns the FileInfo structure describing file. If there is an error, it will be of type *PathError.

func (*FileSystem) Sub

func (f *FileSystem) Sub(dir string) (fs.FS, error)

Sub returns an fs.FS corresponding to the subtree rooted at dir. The result is wrapped in rofs to maintain read-only guarantee.

func (f *FileSystem) Symlink(oldname, newname string) error

Symlink creates newname as a symbolic link to oldname. If there is an error, it will be of type *LinkError.

func (*FileSystem) TempDir

func (f *FileSystem) TempDir() string

func (*FileSystem) Truncate

func (f *FileSystem) Truncate(name string, size int64) error

Jump to

Keyboard shortcuts

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