本文整理汇总了Golang中github.com/ipfs/go-ipfs/commands/files.File.NextFile方法的典型用法代码示例。如果您正苦于以下问题:Golang File.NextFile方法的具体用法?Golang File.NextFile怎么用?Golang File.NextFile使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类github.com/ipfs/go-ipfs/commands/files.File
的用法示例。
在下文中一共展示了File.NextFile方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Golang代码示例。
示例1: addDir
func (adder *Adder) addDir(dir files.File) error {
log.Infof("adding directory: %s", dir.FileName())
err := mfs.Mkdir(adder.mr, dir.FileName(), true, false)
if err != nil {
return err
}
for {
file, err := dir.NextFile()
if err != nil && err != io.EOF {
return err
}
if file == nil {
break
}
// Skip hidden files when adding recursively, unless Hidden is enabled.
if files.IsHidden(file) && !adder.Hidden {
log.Infof("%s is hidden, skipping", file.FileName())
continue
}
err = adder.addFile(file)
if err != nil {
return err
}
}
return nil
}
示例2: addDir
func addDir(n *core.IpfsNode, dir files.File) (*merkledag.Node, error) {
tree := &merkledag.Node{Data: unixfs.FolderPBData()}
Loop:
for {
file, err := dir.NextFile()
switch {
case err != nil && err != io.EOF:
return nil, err
case err == io.EOF:
break Loop
}
node, err := addFile(n, file)
if err != nil {
return nil, err
}
_, name := gopath.Split(file.FileName())
if err := tree.AddNodeLink(name, node); err != nil {
return nil, err
}
}
if err := addNode(n, tree); err != nil {
return nil, err
}
return tree, nil
}
示例3: addDir
func (adder *Adder) addDir(dir files.File) error {
log.Infof("adding directory: %s", dir.FileName())
err := mfs.Mkdir(adder.mr, dir.FileName(), true, false)
if err != nil {
return err
}
for {
file, err := dir.NextFile()
if err != nil && err != io.EOF {
return err
}
if file == nil {
break
}
err = adder.addFile(file)
if _, ok := err.(*hiddenFileError); ok {
// hidden file error, skip file
continue
} else if err != nil {
return err
}
}
return nil
}
示例4: addDir
func (params *adder) addDir(file files.File) (*dag.Node, error) {
tree := &dag.Node{Data: ft.FolderPBData()}
log.Infof("adding directory: %s", file.FileName())
for {
file, err := file.NextFile()
if err != nil && err != io.EOF {
return nil, err
}
if file == nil {
break
}
node, err := params.addFile(file)
if _, ok := err.(*hiddenFileError); ok {
// hidden file error, set the node to nil for below
node = nil
} else if err != nil {
return nil, err
}
if node != nil {
_, name := path.Split(file.FileName())
err = tree.AddNodeLink(name, node)
if err != nil {
return nil, err
}
}
}
err := outputDagnode(params.out, file.FileName(), tree)
if err != nil {
return nil, err
}
k, err := params.node.DAG.Add(tree)
if err != nil {
return nil, err
}
params.node.Pinning.GetManual().PinWithMode(k, pin.Indirect)
return tree, nil
}
示例5: addDir
func addDir(n *core.IpfsNode, dir files.File, out chan interface{}, progress bool, useTrickle bool) (*dag.Node, error) {
log.Infof("adding directory: %s", dir.FileName())
tree := &dag.Node{Data: ft.FolderPBData()}
for {
file, err := dir.NextFile()
if err != nil && err != io.EOF {
return nil, err
}
if file == nil {
break
}
node, err := addFile(n, file, out, progress, false, useTrickle)
if err != nil {
return nil, err
}
_, name := path.Split(file.FileName())
err = tree.AddNodeLink(name, node)
if err != nil {
return nil, err
}
}
err := outputDagnode(out, dir.FileName(), tree)
if err != nil {
return nil, err
}
k, err := n.DAG.Add(tree)
if err != nil {
return nil, err
}
n.Pinning.GetManual().PinWithMode(k, pin.Indirect)
return tree, nil
}