func TestReadEmptyDirectory(t *testing.T) { var dir string var err error if dir, err = ioutil.TempDir(os.TempDir(), "TestReadEmptyDirectory"); err != nil { t.Fail() return } defer os.Remove(dir) assert.Len(t, fs.ReadDir(dir), 0) }
func TestReadDir(t *testing.T) { var dir string var err error if dir, err = ioutil.TempDir(os.TempDir(), "TestReadDir"); err != nil { t.Fail() return } defer os.RemoveAll(dir) ioutil.TempFile(dir, "1.mkv") ioutil.TempFile(dir, "2.mp4") ioutil.TempFile(dir, "3.avi") assert.Len(t, fs.ReadDir(dir), 3) }
func ExtractFilesFromArgs(args []string) (files []string) { for _, arg := range args { fi, err := os.Stat(arg) if err != nil { continue } abs, err := filepath.Abs(arg) if err != nil { continue } if fi.IsDir() { files = append(files, fs.ReadDir(abs)...) continue } files = append(files, abs) } return files }