Example #1
0
File: dir.go Project: jgluck/bazil
func (d *dir) reviveDir(de *wire.Dirent, name string) (*dir, error) {
	if de.Type.Dir == nil {
		return nil, fmt.Errorf("tried to revive non-directory as directory: %v", de.GetValue())
	}
	child := &dir{
		inode:  de.Inode,
		name:   name,
		parent: d,
		fs:     d.fs,
		active: make(map[string]node),
	}
	return child, nil
}
Example #2
0
File: dir.go Project: jgluck/bazil
func (d *dir) reviveNode(de *wire.Dirent, name string) (node, error) {
	switch {
	case de.Type.Dir != nil:
		return d.reviveDir(de, name)

	case de.Type.File != nil:
		manifest := de.Type.File.Manifest.ToBlob("file")
		blob, err := blobs.Open(d.fs.chunkStore, manifest)
		if err != nil {
			return nil, err
		}
		child := &file{
			inode:  de.Inode,
			name:   name,
			parent: d,
			blob:   blob,
		}
		return child, nil
	}

	return nil, fmt.Errorf("dirent unknown type: %v", de.GetValue())
}