コード例 #1
0
ファイル: ipns_unix.go プロジェクト: rdterner/go-ipfs
// ReadDirAll reads the link structure as directory entries
func (dir *Directory) ReadDirAll(ctx context.Context) ([]fuse.Dirent, error) {
	var entries []fuse.Dirent
	for _, name := range dir.dir.List() {
		dirent := fuse.Dirent{Name: name}

		// TODO: make dir.dir.List() return dirinfos
		child, err := dir.dir.Child(name)
		if err != nil {
			return nil, err
		}

		switch child.Type() {
		case nsfs.TDir:
			dirent.Type = fuse.DT_Dir
		case nsfs.TFile:
			dirent.Type = fuse.DT_File
		}

		entries = append(entries, dirent)
	}

	if len(entries) > 0 {
		return entries, nil
	}
	return nil, fuse.ENOENT
}
コード例 #2
0
ファイル: ipns_unix.go プロジェクト: palkeo/go-ipfs
// ReadDirAll reads the link structure as directory entries
func (dir *Directory) ReadDirAll(ctx context.Context) ([]fuse.Dirent, error) {
	var entries []fuse.Dirent
	listing, err := dir.dir.List()
	if err != nil {
		return nil, err
	}
	for _, entry := range listing {
		dirent := fuse.Dirent{Name: entry.Name}

		switch mfs.NodeType(entry.Type) {
		case mfs.TDir:
			dirent.Type = fuse.DT_Dir
		case mfs.TFile:
			dirent.Type = fuse.DT_File
		}

		entries = append(entries, dirent)
	}

	if len(entries) > 0 {
		return entries, nil
	}
	return nil, fuse.ENOENT
}