diskfs

package module
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: Mar 24, 2024 License: MIT Imports: 18 Imported by: 1

README

diskfs

A library to handle disk I/O operations

Documentation

Index

Constants

This section is empty.

Variables

View Source
var Fetch = os.ReadFile

Functions

func AbsPath

func AbsPath(path string) (abspath string, err error)

AbsPath creates absolute path for a filename

func CheckPath

func CheckPath(path string, options []Option) bool

func Chmod

func Chmod(path string, perm any) error

func CopyFile

func CopyFile(src string, dst string, options ...Option) (err error)

CopyFile copies a file to another file or to a directory - src: sourcefile - dst: destination (if a directory, the basename of src is appended) options:

backupdir: if destination exists, it is copied to this directory
keepperm: copies permissions and ownership to the destination
keepmtime: copies mtime of source to destination

func Index

func Index(r io.Reader, needles ...[]byte) (index int64, err error)

func Info

func Info(path string) map[string]string

func IsDir

func IsDir(path string) bool

IsDir returns true if path is a directory

func IsPath

func IsPath(path string) bool

IsPath returns true if path exists

func IsReadable

func IsReadable(path string) bool

IsReadable returns true if path is readable

func IsRegular

func IsRegular(path string) bool

IsRegular returns true if path is a regular file

func IsWritable

func IsWritable(path string) bool

IsWriteable returns true if path is writeable

func List

func List(dir string, options ...Option) (files []string, err error)

func MakeByteFinder

func MakeByteFinder(pattern []byte) *byteFinder

func Mkdir

func Mkdir(path string, options ...Option) (abspath string, err error)

func NextPath

func NextPath(name string) string

func OnAbsPath

func OnAbsPath(c *Config)

func Perm

func Perm(perm any) os.FileMode

Perm translates the rwxrwxrwx permission indicators to a os.FileMode. There are a few predefined filetypes

func RmPath

func RmPath(path string) error

func SHA1

func SHA1(fname string) (string, error)

func Store

func Store(path string, data interface{}, options ...Option) (err error)

Store ...

func TempDir

func TempDir(dir string, options ...Option) (abspath string, err error)

TempDir creates a temporary subdirectory in dir

Options:

prefix: a prefix for the temporary dir
suffix: a suffix for the temporary dir

func Unzip

func Unzip(zipfile string, dir string, options ...Option) (files []string, err error)

func WithAtomic

func WithAtomic(c *Config)

func WithKeepMTime

func WithKeepMTime(c *Config)

func WithKeepPerm

func WithKeepPerm(c *Config)

func WithLower

func WithLower(c *Config)

func WithOnlyDirs

func WithOnlyDirs(c *Config)

func WithOnlyFiles

func WithOnlyFiles(c *Config)

func WithRecurse

func WithRecurse(c *Config)

func Zip

func Zip(dir string, zipfile string, options ...Option) (err error)

Types

type Config

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

func NewCfg

func NewCfg(opts []Option) Config

func (Config) IsOption

func (config Config) IsOption(s string) bool

type Option

type Option func(*Config)

func WithBackupDir

func WithBackupDir(path string) Option

func WithContent

func WithContent[S ~string | []byte](content S) Option

func WithCreateDir

func WithCreateDir(perm any) Option

func WithMTimeAfter

func WithMTimeAfter(t *time.Time) Option

func WithMTimeBefore

func WithMTimeBefore(t *time.Time) Option

func WithPerm

func WithPerm(perm any) Option

func WithPrefix

func WithPrefix(prefix string) Option

func WithSuffix

func WithSuffix(suffix string) Option

Jump to

Keyboard shortcuts

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