-
Notifications
You must be signed in to change notification settings - Fork 0
/
structs.go
122 lines (102 loc) · 2.44 KB
/
structs.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
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
package onearchiver
import (
"github.com/yeka/zip"
"os"
"time"
)
type allowedSecondExtMap map[string]string
type ArchiveFileInfo struct {
Mode os.FileMode
Size int64
IsDir bool
ModTime time.Time
Name string
FullPath string
ParentPath string
Extension string
}
type ArchiveMeta struct {
Filename string
Password string
GitIgnorePattern []string
EncryptionMethod zip.EncryptionMethod
}
type ArchiveRead struct {
ListDirectoryPath string
OrderBy ArchiveOrderBy
OrderDir ArchiveOrderDir
Recursive bool
}
type ArchivePack struct {
FileList []string
}
type ArchiveUnpack struct {
FileList []string
Destination string
}
type filePathListSortInfo struct {
splittedPaths [2]string
IsDir bool
Mode os.FileMode
Size int64
ModTime time.Time
Name string
FullPath string
ParentPath string
Extension string
}
type zipArchive struct {
meta ArchiveMeta // required
read ArchiveRead // required for listing files
pack ArchivePack // required for archiving files
unpack ArchiveUnpack // required for unarchiving files
}
type commonArchive struct {
meta ArchiveMeta // required
read ArchiveRead // required for listing files
pack ArchivePack // required for archiving files
unpack ArchiveUnpack // required for unarchiving files
}
type ArchiveReader interface {
list() ([]ArchiveFileInfo, error)
}
type ArchiveUtils interface {
isEncrypted() (EncryptedArchiveInfo, error)
}
type ArchivePacker interface {
doPack(ph *ProgressHandler) error
}
type ArchiveUnpacker interface {
doUnpack(ph *ProgressHandler) error
}
type createArchiveFileInfo struct {
absFilepath, relativeFilePath string
isDir bool
fileInfo *os.FileInfo
}
type extractZipFileInfo struct {
absFilepath, name string
fileInfo *os.FileInfo
zipFileInfo *zip.File
}
type extractCommonArchiveFileInfo struct {
absFilepath, name string
fileInfo *ArchiveFileInfo
fileBytes *[]byte
}
type EncryptedArchiveInfo struct {
IsEncrypted bool
IsValidPassword bool
}
type ProgressInfo struct {
StartTime time.Time
TotalFiles int
ProgressCount int
CurrentFilename string
ProgressPercentage float32
}
type ProgressHandler struct {
OnReceived func(*ProgressInfo)
OnError func(error, *ProgressInfo)
OnCompleted func(*ProgressInfo)
}