Beispiel #1
0
func (driver *MemDriver) DirContents(path string) (files []os.FileInfo) {
	files = []os.FileInfo{}
	switch path {
	case "/":
		files = append(files, graval.NewDirItem("files"))
		files = append(files, graval.NewFileItem("one.txt", len(fileOne)))
	case "/files":
		files = append(files, graval.NewFileItem("two.txt", len(fileOne)))
	}
	return files
}
Beispiel #2
0
func fillDirContentsInfo(entities []virtualEntity) []os.FileInfo {
	contents := []os.FileInfo{}

	for _, entity := range entities {
		switch {
		case entity.File != nil:
			contents = append(contents, graval.NewFileItem(entity.Name, entity.File.Size))
		case entity.Folder != nil:
			contents = append(contents, graval.NewDirItem(entity.Name))
		}
	}

	return contents
}
Beispiel #3
0
func (driver *SwiftDriver) DirContents(path string) (files []os.FileInfo) {
	path = scoped_path_with_trailing_slash(driver.user, path)
	log.Printf("DirContents: %s", path)
	opts := &swift.ObjectsOpts{Prefix: path, Delimiter: '/'}
	objects, err := driver.connection.ObjectsAll(driver.container, opts)
	if err != nil {
		return // error connecting to cloud files
	}
	for _, object := range objects {
		tail := strings.Replace(object.Name, path, "", 1)
		basename := strings.Split(tail, "/")[0]
		if object.ContentType == "application/directory" && object.SubDir == "" {
			files = append(files, graval.NewDirItem(basename))
		} else if object.ContentType != "application/directory" {
			files = append(files, graval.NewFileItem(basename, int(object.Bytes)))
		}
	}
	return
}