-
Notifications
You must be signed in to change notification settings - Fork 0
/
files.go
57 lines (48 loc) · 1.2 KB
/
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
package pack
import (
"os"
"git.fractalqb.de/fractalqb/gomk"
pk "git.fractalqb.de/fractalqb/pack"
)
type OsDepNames = pk.OsDepNames
var OsDepExe = pk.OsDepExe
func CopyFile(dir *gomk.Dir, dst, src string, osdn OsDepNames) error {
ddir := dir.Join(dst)
sdir := dir.Join(src)
return pk.CopyFile(ddir.Abs(), sdir.Abs(), osdn)
}
func CopyToDir(dir *gomk.Dir, dst string, osdn OsDepNames, files ...string) error {
fls := make([]string, 0, len(files))
for _, f := range files {
fls = append(fls, dir.Join(f).Abs())
}
return pk.CopyToDir(dir.Join(dst).Abs(), osdn, fls...)
}
// TODO NYI
// func CollectToDir(
// dir *gomk.WDir,
// dst, root string,
// filter func(dir string, file os.FileInfo) bool,
// osdn OsDepNames,
// ) error {
// }
func CopyRecursive(
dir *gomk.Dir,
dst, src string,
filter func(dir string, info os.FileInfo) bool,
osdn OsDepNames,
) error {
ddir := dir.Join(dst)
sdir := dir.Join(src)
return pk.CopyRecursive(ddir.Abs(), sdir.Abs(), filter, osdn)
}
func CopyTree(
dir *gomk.Dir,
dst, src string,
filter func(dir string, info os.FileInfo) bool,
osdn OsDepNames,
) error {
ddir := dir.Join(dst)
sdir := dir.Join(src)
return pk.CopyTree(ddir.Abs(), sdir.Abs(), filter, osdn)
}