コード例 #1
0
ファイル: graval-mem.go プロジェクト: yob/graval
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
}
コード例 #2
0
ファイル: httpDriver.go プロジェクト: jakobwesthoff/http2ftp
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
}
コード例 #3
0
ファイル: graval-swift.go プロジェクト: pzduniak/graval
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
}