Exemplo n.º 1
0
		dir:     d,
		name:    name,
		writers: 1,
		// file is empty at Create time, no need to set data
	}

	return f, f, d.fs.backend.Update(c, func(ctx Context) error {
		b, err := ctx.Dir(d.path)
		if err != nil {
			return err
		}
		return b.Create(name)
	})
}

var _ = fs.NodeRemover(&Dir{})

func (d *Dir) Remove(c context.Context, req *fuse.RemoveRequest) error {
	name := req.Name
	return d.fs.backend.Update(c, func(ctx Context) error {
		b, err := ctx.Dir(d.path)
		if err != nil {
			return err
		}
		if b == nil {
			return errors.New("dir no longer exists")
		}

		switch req.Dir {
		case true:
			if d, err := b.GetDir(name); err != nil {
Exemplo n.º 2
0
Arquivo: dir.go Projeto: jgluck/bazil
	// each in-memory child, so we can return the same node on
	// multiple Lookups and know what to do on .save()
	//
	// each child also stores its own name; if the value in the child,
	// looked up in this map, does not equal the child, that means the
	// child has been unlinked
	active map[string]node
}

var _ = node(&dir{})
var _ = fs.Node(&dir{})
var _ = fs.NodeCreater(&dir{})
var _ = fs.NodeForgetter(&dir{})
var _ = fs.NodeMkdirer(&dir{})
var _ = fs.NodeRemover(&dir{})
var _ = fs.NodeRenamer(&dir{})
var _ = fs.NodeStringLookuper(&dir{})
var _ = fs.HandleReadDirer(&dir{})

func (d *dir) setName(name string) {
	d.mu.Lock()
	defer d.mu.Unlock()
	d.name = name
}

func (d *dir) Attr() fuse.Attr {
	return fuse.Attr{
		Inode: d.inode,
		Mode:  os.ModeDir | 0755,
		Nlink: 1,