fsw

package
v1.8.0 Latest Latest
Warning

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

Go to latest
Published: Aug 15, 2023 License: MIT Imports: 7 Imported by: 2

Documentation

Overview

fsw is a package with simple methods to work with filesystems.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CutBOMFromString

func CutBOMFromString(str string) string

CutBOMFromString returns string with byte order mark removed in case it exists at the start of the string.

Useful for reading UTF-8 files

func MakePathToFile

func MakePathToFile(path string, truncate bool) (*os.File, error)

MakePathToFile creates full path to file in filesystem, creates the file and truncates in case truncate = true.

Useful in cases where there is no need to check content (logs, for example).

Types

type IFile

type IFile interface {
	Chdir() error
	Chmod(mode fs.FileMode) error
	Chown(uid int, gid int) error
	Close() error
	Fd() uintptr
	Name() string
	Read(b []byte) (n int, err error)
	ReadAt(b []byte, off int64) (n int, err error)
	ReadDir(n int) ([]fs.DirEntry, error)
	ReadFrom(r io.Reader) (n int64, err error)
	Readdir(n int) ([]fs.FileInfo, error)
	Readdirnames(n int) (names []string, err error)
	Seek(offset int64, whence int) (ret int64, err error)
	SetDeadline(t time.Time) error
	SetReadDeadline(t time.Time) error
	SetWriteDeadline(t time.Time) error
	Stat() (fs.FileInfo, error)
	Sync() error
	SyscallConn() (syscall.RawConn, error)
	Truncate(size int64) error
	Write(b []byte) (n int, err error)
	WriteAt(b []byte, off int64) (n int, err error)
	WriteString(s string) (n int, err error)
}

IFile represents file in the filesystem

type IFileReader

type IFileReader interface {
	Close() error
	Read(b []byte) (n int, err error)
}

IFileReader is an interface to mock file reading operations

type IFileWriter

type IFileWriter interface {
	Close() error
	Write(b []byte) (n int, err error)
	WriteString(s string) (n int, err error)
}

IFileWriter is an interface to mock file writing operations

Jump to

Keyboard shortcuts

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