filehandler

package
v1.1.14 Latest Latest
Warning

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

Go to latest
Published: Jun 17, 2024 License: GPL-3.0 Imports: 13 Imported by: 3

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func GetFileHash added in v0.4.7

func GetFileHash[T any](fh *FileHash, key string) (it T, ok bool)

func HashFile

func HashFile(Fo *FileBasic, bs *BytesStore) (hash string, err error)

func WriteJson

func WriteJson(Fo *FileBasic, v any) (err error)

Types

type BytesStore

type BytesStore struct {
	bytes.Buffer
	// contains filtered or unexported fields
}

func NewBytesStore

func NewBytesStore() (bs *BytesStore)

func (*BytesStore) Hash

func (bs *BytesStore) Hash() (hash string, err error)

type FileBasic

type FileBasic struct {
	Path     string   `json:"path"`
	FileType FileType `json:"type"`
	Size     int64    `json:"size"`
	// directly read write to the file
	*os.File
	// contains filtered or unexported fields
}

func Create

func Create(file_path string) (Fo *FileBasic, err error)

func NewFileBasic

func NewFileBasic(path string) (Fo *FileBasic)

func Open

func Open(file_path string) (Fo *FileBasic, err error)

func (*FileBasic) Fs

func (Fo *FileBasic) Fs() os.FileInfo

func (*FileBasic) Info added in v0.4.5

func (Fo *FileBasic) Info() (os.FileInfo, error)

func (*FileBasic) IsDir added in v0.4.5

func (Fo *FileBasic) IsDir() bool

func (*FileBasic) IsOpen

func (Fo *FileBasic) IsOpen() bool

func (*FileBasic) ModTime

func (Fo *FileBasic) ModTime() string

func (*FileBasic) ReadAll

func (Fo *FileBasic) ReadAll() (data []byte, err error)

func (*FileBasic) Type

func (Fo *FileBasic) Type() fs.FileMode

type FileHash

type FileHash struct {
	*FileBasic
	Hash     string         `json:"hash"`
	ModTime  string         `json:"last_mod_time"`
	MetaData map[string]any `json:"meta_data"`
}

func NewFileHashCreate

func NewFileHashCreate(file_path string) (Fh *FileHash, err error)

func NewFileHashOpen

func NewFileHashOpen(file_path string) (Fh *FileHash, err error)

func (*FileHash) Get added in v0.4.7

func (fh *FileHash) Get(key string) (it any, ok bool)

func (*FileHash) Set added in v0.4.7

func (fh *FileHash) Set(key string, val any)

type FileType

type FileType string

func Ext

func Ext(Fo *FileBasic) FileType

type LockFile added in v0.4.6

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

func Lock added in v0.4.6

func Lock(file_path string) (lf *LockFile, err error)

func (*LockFile) Unlock added in v0.4.6

func (lf *LockFile) Unlock() error

Jump to

Keyboard shortcuts

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