/
archivist.go
53 lines (45 loc) · 1.14 KB
/
archivist.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
package archivist
import (
"os"
"path/filepath"
)
var (
perm os.FileMode = os.ModeDir|0700
bufSize int = 1<<20 // ~1MB default
)
// Zip is an exported method which sanitizes io paths and starts archiving
func Zip(src, dst string) error {
z := &zipper{
src: filepath.Clean(filepath.FromSlash(src)),
dst: filepath.Clean(filepath.FromSlash(dst)),
}
return z.do()
}
// Unzip is an exported method which sanitizes io paths and starts unzipping
func Unzip(src, dst string) error {
z := &unzipper{
src: filepath.Clean(filepath.FromSlash(src)),
dst: filepath.Clean(filepath.FromSlash(dst)),
}
return z.do()
}
func Tar(src, dst string) error {
t := &tarmonster{
src: filepath.Clean(filepath.FromSlash(src)),
dst: filepath.Clean(filepath.FromSlash(dst)),
}
return t.do()
}
func Untar(src, dst string) error {
t := &untarmonster{
src: filepath.Clean(filepath.FromSlash(src)),
dst: filepath.Clean(filepath.FromSlash(dst)),
}
return t.do()
}
func SetFileMode(mode os.FileMode) {
perm = mode
}
func SetBufferSize(size int) {
bufSize = size
}