Example #1
0
func (dir Dir) Lookup(ctx context.Context, name string) (fs.Node, error) {
	files_result, e := filer.ListFiles(*mountOptions.filer, dir.Path, name)
	if e != nil {
		return nil, fuse.ENOENT
	}
	if len(files_result.Files) > 0 {
		return File{files_result.Files[0].Id, files_result.Files[0].Name}, nil
	}
	return nil, fmt.Errorf("File Not Found for %s", name)
}
Example #2
0
func (dir *Dir) ReadDir(ctx context.Context) ([]fuse.Dirent, error) {
	var ret []fuse.Dirent
	if dirs, e := filer.ListDirectories(*mountOptions.filer, dir.Path); e == nil {
		for _, d := range dirs.Directories {
			dirId := uint64(d.Id)
			ret = append(ret, fuse.Dirent{Inode: dirId, Name: d.Name, Type: fuse.DT_Dir})
		}
	}
	if files, e := filer.ListFiles(*mountOptions.filer, dir.Path, ""); e == nil {
		for _, f := range files.Files {
			if fileId, e := storage.ParseFileId(string(f.Id)); e == nil {
				fileInode := uint64(fileId.VolumeId)<<48 + fileId.Key
				ret = append(ret, fuse.Dirent{Inode: fileInode, Name: f.Name, Type: fuse.DT_File})
			}

		}
	}
	return ret, nil
}