func (d *Directory) Create(name string, dir bool) (*Directory, *File, error) { d.Obj.Lock() defer d.Obj.Unlock() _, e := d.Res.Dir.Find(name) if e == nil { return nil, nil, syscall.EEXIST } id := uuid.NewV4().String() res := resource.NewResource(d.Repo.Repo, id) if dir { e = joinf.CreateDir(res) } else { e = joinf.CreateFile(res) } res.Dispose() if e != nil { return nil, nil, e } e = d.Res.Dir.Insert(name, id) if e != nil { d.Repo.Repo.Delete(id) return nil, nil, e } return d.load(id) }
func (m *MNode) makeKnot(name string,isDir bool) (*nodefs.Inode,*MNode,fuse.Status) { m.obj.Lock() defer m.obj.Unlock() d,ok := m.obj.Obj.(*joinf.Directory) if !ok { return nil,nil,fuse.ENOTDIR } { c := m.Inode().GetChild(name) if c!=nil { return nil,nil,fuse.Status(syscall.EEXIST) } id,_ := d.Find(name) if id!="" { return nil,nil,fuse.Status(syscall.EEXIST) } } id := uuid.NewV4().String() if isDir { r := m.lm.Dirs(id) e := joinf.CreateDir(r) if e!=nil { return nil,nil,fuse.ToStatus(e) } e = d.Insert(name,id) if e!=nil { r.Delete() return nil,nil,fuse.ToStatus(e) } r.Dispose() }else{ r := m.lm.Files(id) e := joinf.CreateFile(r) if e!=nil { return nil,nil,fuse.ToStatus(e) } e = d.Insert(name,id) if e!=nil { r.Delete() return nil,nil,fuse.ToStatus(e) } r.Dispose() } co := m.lm.Load(id) nin := &MNode{nodefs.NewDefaultNode(),m.lm,co} return m.Inode().NewChild(name,isDir,nin),nin,fuse.OK }