-
Notifications
You must be signed in to change notification settings - Fork 0
/
linux_files.go
57 lines (49 loc) · 1.31 KB
/
linux_files.go
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
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
// +build linux
package main
import (
"fmt"
"io/ioutil"
"path/filepath"
)
// GetAllFiles: Get all files in the given directory and all sub directories
func GetAllFiles(_startDir string) []string {
if DEBUG == true {
fmt.Println(fmt.Sprintf(UI_Arguments, GetFunctionName()), "_startDir: ", _startDir)
}
if len(_startDir) > 0 {
files, err := ioutil.ReadDir(_startDir)
if err != nil {
if DEBUG == true {
fmt.Println(UI_DirectoryReadFail, _startDir)
}
} else {
for _, file := range files {
fmt.Printf("\rBuilding Files.")
if file.IsDir() {
if skipDirs != nil && len(skipDirs) > 0 {
if SkipDir(file.Name()) == true {
if DEBUG == true {
fmt.Println(UI_SkippingDirectory, file.Name())
}
skippedDirectoriesCount++
} else {
subDir := filepath.Join(_startDir, file.Name())
fmt.Printf("\rBuilding Files..")
GetAllFiles(subDir)
}
} else {
subDir := filepath.Join(_startDir, file.Name())
fmt.Printf("\rBuilding Files..")
GetAllFiles(subDir)
}
} else {
fmt.Printf("\rBuilding Files...")
allFiles = append(allFiles, _startDir+"/"+file.Name())
}
} // end for
}
} else {
fmt.Println(fmt.Sprintf(UI_ParameterInvalid, GetFunctionName()), "_startDir: ", _startDir)
}
return allFiles
}