-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy patharchive.go
96 lines (79 loc) · 2.25 KB
/
archive.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
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
package shutil
import "fmt"
// ArchiveFormat obj
type ArchiveFormat struct {
Name string
Sufix []string
Desc string
}
func (af ArchiveFormat) String() string {
return fmt.Sprintf("\nName:%s\nSufix:%v\nDesc:%v\n",
af.Name, af.Sufix, af.Desc)
}
// RegisterArchiveFormat Register an archiver for the format name.
func RegisterArchiveFormat(name string, f func()) (err error) {
return
}
// UnRegisterArchiveFormat Remove the archive format name from the list of supported formats.
func UnRegisterArchiveFormat(name string) (err error) {
return
}
// GetArchiveFormats Return a list of supported formats for archiving
func GetArchiveFormats() (afs []*ArchiveFormat) {
afs = []*ArchiveFormat{
{"bztar", []string{".tar.bz2", ".tbz2"}, "bzip2'ed tar-file"},
{"gztar", []string{".tar.gz", ".tgz"}, "gzip'ed tar-file"},
{"tar", []string{".tar"}, "uncompressed tar file"},
{"xztar", []string{".tar.xz", ".txz"}, "xz'ed tar-file"},
{"zip", []string{".zip"}, "ZIP file"},
}
return
}
// MakeOpt obj
type MakeOpt struct {
Name string
Format string
RootDir string
BaseDir string
Verbose bool
DryRun bool
Owner int64
Group int64
Logger string
}
// MakeArchive Create an archive file (such as zip or tar) and return its name.
func MakeArchive(opt *MakeOpt) (err error) {
return
}
// RegisterUnpackFormat Registers an unpack format.
func RegisterUnpackFormat(name string, f func()) (err error) {
return
}
// UnRegisterUnpackFormat Unregister an unpack format. name is the name of the format.
func UnRegisterUnpackFormat(name string) (err error) {
return
}
// GetUnpackFormats Return a list of all registered formats for unpacking.
func GetUnpackFormats() (afs []*ArchiveFormat) {
afs = []*ArchiveFormat{
{"bztar", []string{".tar.bz2", ".tbz2"}, "bzip2'ed tar-file"},
{"gztar", []string{".tar.gz", ".tgz"}, "gzip'ed tar-file"},
{"tar", []string{".tar"}, "uncompressed tar file"},
{"xztar", []string{".tar.xz", ".txz"}, "xz'ed tar-file"},
{"zip", []string{".zip"}, "ZIP file"},
}
return
}
// UnpackOpt obj
type UnpackOpt struct {
Filename string
ExtractDir string
Format string
}
// UnpackArchive Unpack an archive. filename is the full path of the archive.
func UnpackArchive(opt *UnpackOpt) {
}
/*
make_archive
shutil.register_archive_format
*/