summaryrefslogtreecommitdiff
path: root/internal/local/files.go
blob: e4b4f67afd72b2e9faeb357ba0c06b1a1e536105 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
package local

import (
	"os"
	"path/filepath"
)

// GetFiles retrieves a map of files in the local destination directory
func GetFiles(destDir string) (map[string]bool, error) {
	files := make(map[string]bool)

	err := filepath.Walk(destDir, func(path string, info os.FileInfo, err error) error {
		if err != nil {
			return err
		}

		if !info.IsDir() {
			// Get relative path
			relPath, err := filepath.Rel(destDir, path)
			if err != nil {
				return err
			}
			files[relPath] = true
		}

		return nil
	})

	return files, err
}