hos

package
v1.3.2 Latest Latest
Warning

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

Go to latest
Published: Jul 6, 2023 License: Apache-2.0 Imports: 11 Imported by: 1

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrInvalidWrite = errors.New("invalid write result")

Functions

func CopyFile

func CopyFile(dst string, src string) (written int64, err error)

CopyFile copies from src to dst until either an error occurs. It returns the number of bytes copied and the first error encountered while copying, if any.

A successful CopyFile returns err == nil, not err == EOF. Because CopyFile is defined to read from src until EOF, it does not treat an EOF from Read as an error to be reported.

func CopyFileWatcher

func CopyFileWatcher(dst string, src string, buf []byte, listener IOProgressListener) (written int64, err error)

CopyFileWatcher is identical to CopyBuffer except that it provided listener (if one is required).

func CreateFolder

func CreateFolder(p string, ignoreExists bool) error

func FileExists

func FileExists(filename string) bool

func FileNameWithoutExt

func FileNameWithoutExt(filename string) string

FileNameWithoutExt filename without extension

func FolderExists

func FolderExists(filename string) bool

func GetGoroutineId

func GetGoroutineId() uint64

func MoveFile

func MoveFile(dst string, src string) (written int64, err error)

MoveFile move from src to dst until either an error occurs. It returns the number of bytes move and the first error encountered while moving, if any.

A successful MoveFile returns err == nil, not err == EOF. Because MoveFile is defined to read from src until EOF, it does not treat an EOF from Read as an error to be reported.

func MoveFileWatcher

func MoveFileWatcher(dst string, src string, buf []byte, listener IOProgressListener) (written int64, err error)

MoveFileWatcher is identical to CopyFileWatcher except that it remove the source file when completes

func NewFilename

func NewFilename(filename string, tries int, rule func(name string) string) (string, error)

NewFilename filename exists return new name rule custom name rule

func ReadDir

func ReadDir(name string, ignoreDotFiles bool) (files []os.DirEntry, err error)

func TouchFile

func TouchFile(p string, ignoreExists bool, createFolder bool) error

TouchFile touch empty file, p is filepath ignoreExists - if true file exists return nil, otherwise return err createFolder - if true try to create folder

Types

type FileInfo

type FileInfo struct {
	Name   string
	Path   string
	Mime   types.Type
	Head   []byte
	Width  float64
	Height float64
	Stat   os.FileInfo
}

func GetFileInfo

func GetFileInfo(src string) (fi *FileInfo, err error)

GetFileInfo returns a FileInfo describing the named file. If there is an error, fi = nil.

type IOProgressListener

type IOProgressListener interface {
	ProgressChanged(event *ProgressEvent)
}

type ProgressEvent

type ProgressEvent struct {
	ConsumedBytes int64
	TotalBytes    int64
	EventType     ProgressEventType
}

type ProgressEventType

type ProgressEventType int
const (
	// TransferStartedEvent transfer started, set TotalBytes
	TransferStartedEvent ProgressEventType = 1 + iota
	// TransferDataEvent transfer data, set ConsumedBytes anmd TotalBytes
	TransferDataEvent
	// TransferCompletedEvent transfer completed
	TransferCompletedEvent
	// TransferFailedEvent transfer encounters an error
	TransferFailedEvent
)

Jump to

Keyboard shortcuts

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