driver

package
v0.0.1-20220602-0002 Latest Latest
Warning

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

Go to latest
Published: Jun 2, 2022 License: MIT Imports: 3 Imported by: 1

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Any

type Any = interface{}

type FileCopyStatus

type FileCopyStatus struct {
	PercentageCopied int8
	BytesCopied      int64
	LeftBytes        int64
	// when it will finish
	FinishETA   time.Time
	LeftSeconds int64
}

type FileDestination

type FileDestination struct {
	// FileName -> if necessary you can override the file name
	// it will override even for DirPath & FilePath
	FileName string

	// if none of the lower params are indicated, it will take the current files basedir and it will
	// recreate on the destination location
	//========= Optional Params ===========\\
	// DirPath -> is optional, a new folder path is indicated, the file name remains the same!
	DirPath string

	// FilePath -> is optional, a new full file path is indicated (it includes as the dir path)
	FilePath string

	// FileMode -> is optional, If you need to override the currents file mode, the set here
	FileMode os.FileMode

	// if you want to receive in real time the status (how much left to copy)
	// put a callback handler over here
	OnCopy FileOnCopy
}

FileDestination -> is used when copying or moving to a new destination

type FileInfo

type FileInfo struct {
	ID          *uuid.UUID
	Name        string
	FullName    string
	Path        string
	DirPath     string
	ContentType string
	Size        int64
	Extension   string
	Mode        os.FileMode
	UpdatedAt   time.Time
	CreatedAt   time.Time
	Sys         Any
}

type FileInfoInterface

type FileInfoInterface interface {
	// ToStruct ->  Converts to a struct
	ToStruct() FileInfo

	// ID - is available only when saving to a storage which supports File Identification
	ID() *uuid.UUID
	//
	Name() string
	FullName() string
	//
	Path() string
	DirPath() string

	ContentType() string
	Size() int64
	Extension() string

	Mode() os.FileMode
	//
	UpdatedAt() time.Time
	CreatedAt() time.Time
	// Sys - other system info for this file
	Sys() Any
}

type FileInterface

type FileInterface interface {
	//
	Read() ([]byte, error)
	Info() FileInfoInterface // TODO: we can return all the functions from the current file over there

	// Get location of the file
	Location() LocationInterface
}

type FileOnCopy

type FileOnCopy func(status FileCopyStatus)

type LocationInterface

type LocationInterface interface {
	// Open the location
	Open() (bool, error)

	CopyFile(file FileInterface, dest FileDestination) (FileInterface, error)
	MoveFile(file FileInterface, dest FileDestination) (FileInterface, error)

	// DeleteFile - File status will be used for deletion
	DeleteFile(file FileInterface) error

	// FileFromInfo -> it recreates the file struct/object from FileInfo so further manipulations can be made
	FileFromInfo(fileInfo FileInfo) (FileInterface, error)
	FileFromInfoMap(fileInfo map[string]interface{}) (FileInterface, error)
	FileFromInfoJson(fileInfo string) (FileInterface, error)
}

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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