noncgo

package module
v0.0.0-...-8b2c0d1 Latest Latest
Warning

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

Go to latest
Published: Aug 19, 2022 License: MIT Imports: 11 Imported by: 1

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrExpectedDir = errors.New("expected dir")
)

Functions

This section is empty.

Types

type Branch

type Branch struct {
	Name        string
	Description string
	CommitId    uint64
	Size        uint64
	Count       uint64
}

func NewBranch

func NewBranch(name string, commit Commit, dir Dir) Branch

func (Branch) GetCommitId

func (b Branch) GetCommitId() uint64

func (Branch) GetCount

func (b Branch) GetCount() uint64

func (Branch) GetDescription

func (b Branch) GetDescription() string

func (Branch) GetName

func (b Branch) GetName() string

func (Branch) GetSize

func (b Branch) GetSize() uint64

type Commit

type Commit struct {
	Id uint64

	Hash string
	// contains filtered or unexported fields
}

func NewCommit

func NewCommit(dir Dir, branchName string, message string) Commit

type DB

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

func Open

func Open(dataSourceName string) (*DB, error)

func (*DB) BranchCount

func (db *DB) BranchCount(ctx context.Context) (int, error)

func (*DB) BranchInfo

func (db *DB) BranchInfo(ctx context.Context, branchName string) (branch Branch, err error)

func (*DB) Close

func (db *DB) Close() error

func (*DB) Create

func (db *DB) Create() error

func (*DB) DirCount

func (db *DB) DirCount(ctx context.Context) (int, error)

func (*DB) DirItemCount

func (db *DB) DirItemCount(ctx context.Context) (int, error)

func (*DB) FileCount

func (db *DB) FileCount(ctx context.Context) (int, error)

func (*DB) GetFileHash

func (db *DB) GetFileHash(ctx context.Context, branchName string, splitPath []string) (hash string, err error)

func (*DB) GetFileHashMode

func (db *DB) GetFileHashMode(ctx context.Context, branchName string, splitPath []string) (hash string, mode os.FileMode, err error)

func (*DB) List

func (db *DB) List(ctx context.Context, branchName string, splitPath []string) (dirItems []DirItem, err error)

func (*DB) ListByHash

func (db *DB) ListByHash(ctx context.Context, hash string) (dirItems []DirItem, err error)

func (*DB) NewBranch

func (db *DB) NewBranch(ctx context.Context, branchName string) (exist bool, err error)

func (*DB) Open

func (db *DB) Open(ctx context.Context, branchName string, splitPath []string) (hash string, mode os.FileMode, dirItems []DirItem, err error)

func (*DB) Remove

func (db *DB) Remove(ctx context.Context, branchName string, splitPath []string) (commit Commit, branch Branch, err error)

func (*DB) UpsertDirItem

func (db *DB) UpsertDirItem(ctx context.Context, branchName string, splitPath []string, item DirItem) (commit Commit, branch Branch, err error)

func (*DB) WriteBranch

func (db *DB) WriteBranch(ctx context.Context, branch Branch) error

func (*DB) WriteCommit

func (db *DB) WriteCommit(ctx context.Context, commit *Commit) error

func (*DB) WriteDir

func (db *DB) WriteDir(ctx context.Context, dirItems []DirItem) (dir Dir, err error)

func (*DB) WriteFile

func (db *DB) WriteFile(ctx context.Context, file File) error

type Dir

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

func NewDir

func NewDir(hash string, size uint64, count uint64, totalCount uint64) Dir

func NewDirFromDirItem

func NewDirFromDirItem(item IDirItem) (Dir, error)

func (*Dir) Cal

func (dir *Dir) Cal(dirItems []DirItem)

func (Dir) Count

func (dir Dir) Count() uint64

func (Dir) Hash

func (i Dir) Hash() string

func (Dir) Size

func (i Dir) Size() uint64

func (Dir) TotalCount

func (dir Dir) TotalCount() uint64

type DirItem

type DirItem struct {
	Hash       string
	Name       string
	Mode       uint64
	Size       uint64
	Count      uint64
	TotalCount uint64
	CreateTime uint64 // linux does not support it.
	ModifyTime uint64
	ChangeTime uint64 // windows does not support it.
	AccessTime uint64
}

https://zhuanlan.zhihu.com/p/343682839

func NewDirItem

func NewDirItem(fileOrDir FileOrDir, name string, mode uint64, createTime uint64, modifyTime uint64, changeTime uint64, accessTime uint64) DirItem

func (DirItem) GetAccessTime

func (d DirItem) GetAccessTime() uint64

func (DirItem) GetChangeTime

func (d DirItem) GetChangeTime() uint64

func (DirItem) GetCount

func (d DirItem) GetCount() uint64

func (DirItem) GetCreateTime

func (d DirItem) GetCreateTime() uint64

func (DirItem) GetHash

func (d DirItem) GetHash() string

func (DirItem) GetMode

func (d DirItem) GetMode() uint64

func (DirItem) GetModifyTime

func (d DirItem) GetModifyTime() uint64

func (DirItem) GetName

func (d DirItem) GetName() string

func (DirItem) GetSize

func (d DirItem) GetSize() uint64

func (DirItem) GetTotalCount

func (d DirItem) GetTotalCount() uint64

type File

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

func NewFile

func NewFile(hash string, size uint64) File

func NewFileByBytes

func NewFileByBytes(bytes []byte) File

func (File) Count

func (i File) Count() uint64

func (File) Hash

func (i File) Hash() string

func (File) Size

func (i File) Size() uint64

func (File) TotalCount

func (i File) TotalCount() uint64

type FileOrDir

type FileOrDir interface {
	Hash() string
	Size() uint64
	Count() uint64
	TotalCount() uint64
}

type IBranch

type IBranch interface {
	GetName() string
	GetDescription() string
	GetCommitId() uint64
	GetSize() uint64
	GetCount() uint64
}

type IDirItem

type IDirItem interface {
	GetHash() string
	GetName() string
	GetMode() uint64
	GetSize() uint64
	GetCount() uint64
	GetTotalCount() uint64
	GetCreateTime() uint64
	GetModifyTime() uint64
	GetChangeTime() uint64
	GetAccessTime() uint64
}

type TxOrDb

type TxOrDb interface {
	ExecContext(ctx context.Context, query string, args ...any) (sql.Result, error)
	PrepareContext(ctx context.Context, query string) (*sql.Stmt, error)
}

Jump to

Keyboard shortcuts

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