vfsgo

package module
v0.0.0-...-1370632 Latest Latest
Warning

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

Go to latest
Published: May 5, 2023 License: MIT Imports: 14 Imported by: 0

README

VFSGO

Virtual File System written in Go.

Documentation

Index

Constants

View Source
const (
	SortByName SortType = iota + 1
	SortByCreatedTime

	ASC  string = "ASC"
	DESC string = "DESC"
)
View Source
const (
	BlockINodeFileName = ".blockINode"
)
View Source
const (
	UserINodeFileName = ".userINode"
)

Variables

This section is empty.

Functions

func AttemptUser

func AttemptUser(rootPath, name string) error

func DeleteBlock

func DeleteBlock(user *User, id uint64) error

func DeleteFile

func DeleteFile(block *BlockINode, filename string) error

func DeleteUser

func DeleteUser(rootPath, name string) error

func UpdateFile

func UpdateFile(block *BlockINode, filename, filedescription string) error

Types

type BlockINode

type BlockINode struct {
	// UserPath: user data pool path in real file system
	UserPath string `json:"user_path"`

	PrevNodeID uint64 `json:"prev_node_id"`
	NodeID     uint64 `json:"node_id"`
	// FileMap: file name -> file hash name
	FileMap map[string]FileHeader `json:"file_map"`
}

func CreateBlock

func CreateBlock(block *BlockINode, id uint64) (BlockINode, error)

func GetBlock

func GetBlock(user *User, id uint64) (BlockINode, error)

func (*BlockINode) GetBlockINodePath

func (b *BlockINode) GetBlockINodePath() string

func (*BlockINode) GetBlockPath

func (b *BlockINode) GetBlockPath() string

func (*BlockINode) Save

func (b *BlockINode) Save() error

type FileHeader

type FileHeader struct {
	HashFileName string
	Type         FileType
	DirNodeID    *uint64
	Name         string
	Description  string
	CreatedTime  time.Time
	ModifiedTime time.Time
}

func CreateFile

func CreateFile(block *BlockINode, filename, filedescription string) (FileHeader, error)

func CreateFolder

func CreateFolder(block *BlockINode, nodeid uint64, foldername, desc string) (FileHeader, error)

func GetFile

func GetFile(block *BlockINode, filename string) (FileHeader, error)

func (*FileHeader) Save

func (f *FileHeader) Save(path string) error

type FileType

type FileType int8
const (
	Directory FileType = iota + 1
	File
)

type ICommandService

type ICommandService interface {
	GetCurrentUser() *User
	GetCurrentBlock() *BlockINode

	Register(name string) error
	Use(name string) error
	ChangeFolder(path string) error

	CreateFolder(oldName string) error
	DeleteFolder(oldName string) error
	RenameFolder(oldName string, newName string) error

	CreateFile(fileName, desc string) error
	DeleteFile(fileName string) error
	RenameFile(oldName, newName string, newDesc string) error

	List(dirName string, sortField *SortType, sortOrder *string) ([]string, error)
}

func NewCommandService

func NewCommandService(root string) ICommandService

type SortType

type SortType int

type User

type User struct {
	RootPath      string `json:"root_path"`
	Name          string `json:"name"`
	CurrentNodeID uint64 `json:"current_node_id"`

	BlockMap map[uint64]BlockINode `json:"block_map"`

	CreatedTime time.Time `json:"created_time"`
}

func CreateUser

func CreateUser(rootPath, name string) (User, error)

func GetUser

func GetUser(rootPath, name string) (User, error)

func (*User) GetUserINodePath

func (u *User) GetUserINodePath() string

func (*User) GetUserPath

func (u *User) GetUserPath() string

func (*User) Save

func (u *User) Save() error

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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