sodirs

package
v0.0.0-...-d9d0c30 Latest Latest
Warning

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

Go to latest
Published: Oct 28, 2022 License: Apache-2.0 Imports: 13 Imported by: 0

Documentation

Overview

* @Author: soso * @Date: 2022-01-29 10:25:06 * @LastEditTime: 2022-01-29 18:41:42 * @LastEditors: Please set LastEditors * @Description: 目录的树形结构存储 * @FilePath: /go-mesh-sync/sdirs/node.go

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func HashFileMd5

func HashFileMd5(filename string) (md5str string, err error)

计算文件md5值

Types

type DNode

type DNode struct {
	Name    string      `yaml:"name"`
	Size    int64       `yaml:"size"`
	Mode    fs.FileMode `yaml:"mode"`
	ModTime time.Time   `yaml:"modTime"`
	IsDir   bool        `yaml:"isDir"`

	Level    uint8             `yaml:"level"`
	Md5      string            `yaml:"md5"`
	Children map[string]*DNode `yaml:"children"`
	// contains filtered or unexported fields
}

func NewRootNode

func NewRootNode(path string) (*DNode, error)

func (*DNode) GetParent

func (n *DNode) GetParent() *DNode

func (*DNode) GetPath

func (n *DNode) GetPath() string

节点路径

func (*DNode) GetPathRelWithRoot

func (n *DNode) GetPathRelWithRoot() string

返回针对根节点的相对路径

func (*DNode) IsEmpty

func (n *DNode) IsEmpty() bool

检查节点是不是最终节点

func (*DNode) List

func (n *DNode) List()

控制台打印目录结构

func (*DNode) ListCallBack

func (n *DNode) ListCallBack(cb func(node *DNode))

为节点循环执行回调函数

func (*DNode) ListPath

func (n *DNode) ListPath()

控制台打印目录结构

func (*DNode) Load

func (n *DNode) Load()

加载磁盘数据

func (*DNode) LoadDirStruct

func (n *DNode) LoadDirStruct()

加载目录结构

func (*DNode) Save

func (n *DNode) Save()

写入磁盘数据

func (*DNode) Serialize

func (n *DNode) Serialize() []byte

序列化

func (*DNode) Unserialize

func (n *DNode) Unserialize(buf []byte)

反序列化

Jump to

Keyboard shortcuts

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