Example #1
0
func (d dropboxDriver) List(path string) ([]gofile.File, error) {
	files, err := d.db.Metadata(path, true, false, "", "", 25000)

	if err != nil {
		/** @TODO Handle this properly **/
		return gofile.EmptyFileSet(), err
	}

	if !files.IsDir {
		return gofile.EmptyFileSet(), fmt.Errorf("godropbox: Cannot list files of non directory")
	}

	results := len(files.Contents)
	foundFiles := make([]gofile.File, results)

	for i, file := range files.Contents {
		foundFiles[i] = gofile.File{
			Path:  file.Path,
			IsDir: file.IsDir,
		}
	}

	return foundFiles, nil
}
Example #2
0
func (c localDriver) List(path string) ([]gofile.File, error) {

	dirname := c.absPath(path)

	files, err := ioutil.ReadDir(dirname)

	if err != nil {
		return gofile.EmptyFileSet(), fmt.Errorf("golocal: Could not read directory '%s' (%s)", path, err)
	}

	foundFiles := make([]gofile.File, len(files))

	for i, file := range files {

		fullPath, _ := filepath.Abs(dirname + "/" + file.Name())

		foundFiles[i] = gofile.File{
			Path:  fullPath,
			IsDir: file.IsDir(),
		}
	}

	return foundFiles, nil
}