fileutil

package
v2.0.0-alpha.39 Latest Latest
Warning

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

Go to latest
Published: Aug 31, 2026 License: MIT Imports: 10 Imported by: 44

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type CopyOptions

type CopyOptions struct {
	Overwrite bool // Overwrite replaces the destination file if it already exists.
}

CopyOptions configures a FileManager.CopyFile operation. A nil pointer means default behavior.

type FileManager

type FileManager interface {
	Open(path string) (*os.File, error)
	OpenReaderIfExists(path string) (io.Reader, error)
	ReadDirEntryNames(path string) ([]string, error)
	Remove(path string) error
	RemoveAll(path string) error
	Write(path string, value string, perm os.FileMode) error
	WriteBytes(path string, value []byte) error
	FileSizeInBytes(pth string) (int64, error)
	CopyFile(src, dst string, opts *CopyOptions) error
	CopyFileFS(fsys fs.FS, src, dst string, opts *CopyOptions) error
	CopyDir(src, dst string, opts *CopyOptions) error
	Lstat(path string) (os.FileInfo, error)
	LastNLines(s string, n int) string
}

FileManager ...

func NewFileManager

func NewFileManager() FileManager

NewFileManager ...

type OsProxy

type OsProxy interface {
	Stat(name string) (os.FileInfo, error)
	Lstat(name string) (os.FileInfo, error)
	Readlink(name string) (string, error)
	Symlink(oldname, newname string) error
	Mkdir(name string, perm os.FileMode) error
	MkdirAll(path string, perm os.FileMode) error
	Open(name string) (*os.File, error)
	Create(name string) (*os.File, error)
	Remove(name string) error
	RemoveAll(path string) error
	Rename(oldpath, newpath string) error
	Chmod(name string, mode os.FileMode) error
	Chown(name string, uid, gid int) error
	Chtimes(name string, atime, mtime time.Time) error
	Getwd() (string, error)
	Abs(path string) (string, error)
	DirFS(dir string) fs.FS
	OpenFile(name string, flag int, perm os.FileMode) (*os.File, error)
	Lchown(name string, uid, gid int) error
}

OsProxy defines the subset of os package functions we want to proxy. Add more methods as you need them.

type RealOS

type RealOS struct{}

RealOS is the default implementation that delegates to the real os package.

func (RealOS) Abs

func (RealOS) Abs(path string) (string, error)

func (RealOS) Chmod

func (RealOS) Chmod(name string, mode os.FileMode) error

func (RealOS) Chown

func (RealOS) Chown(name string, uid, gid int) error

func (RealOS) Chtimes

func (RealOS) Chtimes(name string, atime, mtime time.Time) error

func (RealOS) Create

func (RealOS) Create(name string) (*os.File, error)

func (RealOS) DirFS

func (RealOS) DirFS(dir string) fs.FS

func (RealOS) Getwd

func (RealOS) Getwd() (string, error)

func (RealOS) Lchown

func (RealOS) Lchown(name string, uid, gid int) error

func (RealOS) Lstat

func (RealOS) Lstat(name string) (os.FileInfo, error)

func (RealOS) Mkdir

func (RealOS) Mkdir(name string, perm os.FileMode) error

func (RealOS) MkdirAll

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

func (RealOS) Open

func (RealOS) Open(name string) (*os.File, error)

func (RealOS) OpenFile

func (RealOS) OpenFile(name string, flag int, perm os.FileMode) (*os.File, error)
func (RealOS) Readlink(name string) (string, error)

func (RealOS) Remove

func (RealOS) Remove(name string) error

func (RealOS) RemoveAll

func (RealOS) RemoveAll(path string) error

func (RealOS) Rename

func (RealOS) Rename(oldpath, newpath string) error

func (RealOS) Stat

func (RealOS) Stat(name string) (os.FileInfo, error)
func (RealOS) Symlink(oldname, newname string) error

type SysStat

type SysStat struct {
	Uid int
	Gid int
}

SysStat holds file system stat information.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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