1 /******************************************************************************
2 *
3 * Copyright (C) 2009, The Gentee Group. All rights reserved.
4 * This file is part of the Gentee open source project - http://www.gentee.com.
5 *
6 * THIS FILE IS PROVIDED UNDER THE TERMS OF THE GENTEE LICENSE ("AGREEMENT").
7 * ANY USE, REPRODUCTION OR DISTRIBUTION OF THIS FILE CONSTITUTES RECIPIENTS
8 * ACCEPTANCE OF THE AGREEMENT.
9 *
10 * Author: Alexey Krivonogov ( gentee )
11 *
12 ******************************************************************************/
13
14 include
15 {
16 $"gea.g"
17 }
18
19 func uint userfunc( uint code, geaparam param )
20 {
21 if code < $GEAERR_LAST
22 {
23 print( "ERROR: ")
24 }
25 switch code
26 {
27 case $GEAERR_PATTERN
28 {
29 print( "Wrong pattern name: \(param.name)\n")
30 }
31 case $GEAERR_FILEOPEN
32 {
33 switch conrequest( "Cannot open file: \(param.name) (Abort|Retry|Ignore)", "Aa|Rr|Ii" )
34 {
35 case 0 : return $GEA_ABORT
36 case 1 : return $GEA_RETRY
37 case 2 : return $GEA_IGNORE
38 }
39 }
40 case $GEAERR_FILEWRITE
41 {
42 switch conrequest( "Cannot write file: \(param.name) (Abort|Retry)", "Aa|Rr" )
43 {
44 case 0 : return $GEA_ABORT
45 case 1 : return $GEA_RETRY
46 }
47 }
48 case $GEAERR_FILEREAD
49 {
50 switch conrequest( "Cannot read file: \(param.name) (Abort|Retry)", "Aa|Rr" )
51 {
52 case 0 : return $GEA_ABORT
53 case 1 : return $GEA_RETRY
54 }
55 }
56 case $GEAERR_TOOBIG
57 {
58 switch conrequest( "Cannot pack too big file: \(param.name) (Abort|Ignore)", "Aa|Ii" )
59 {
60 case 0 : return $GEA_ABORT
61 case 1 : return $GEA_IGNORE
62 }
63 }
64 case $GEAERR_MANYVOLUMES
65 {
66 print( "Too many volumes: \(param.name)\n")
67 }
68 case $GEAERR_NOTGEA
69 {
70 print( "The file \(param.name) is not GEA archive\n")
71 }
72 case $GEAERR_WRONGVOLUME
73 {
74 print( "The file \(param.name) is the wrong GEA volume\n")
75 }
76 case $GEAERR_WRONGSIZE
77 {
78 print( "The GEA file \(param.name) is less then it should be." )
79 }
80 case $GEAERR_INTERNAL
81 {
82 print( "The internal error \(param.info) in the file \(param.name)\n") }
83 case $GEAERR_CRC
84 {
85 print( "The file \(param.info->geafile.name ) has a wrong CRC\n")
86 }
87 case $GEAMESS_BEGIN
88 {
89 print( "Creating GEA file: \(param.name)\n")
90 }
91 case $GEAMESS_END
92 {
93 print( "GEA file was created successfully\n")
94 }
95 case $GEAMESS_COPY
96 {
97 print( "Duplicate: \(param.name)\n")
98 }
99 case $GEAMESS_ENBEGIN
100 {
101 print( "Packing: \(param.name)\r")
102 }
103 case $GEAMESS_DEBEGIN
104 {
105 print( "Unpacking: \(param.info->geafile.subfolder)\\\(param.info->geafile.name)\r")
106 }
107 case $GEAMESS_WRITEHEAD
108 {
109 print( "Writing GEA header...\n")
110 }
111 case $GEAMESS_DEEND
112 {
113 print( "\(param.info->geafile.subfolder)\\\(param.info->geafile.name) \(param.info->geafile.compsize) to \(param.info->geafile.size)\n")
114 }
115 case $GEAMESS_ENEND
116 {
117 print( "\(param.name) \(param.info->geafile.size) to \(param.info->geafile.compsize) \n")
118 }
119 case $GEAMESS_PROCESS
120 {
121 if param.mode
122 {
123 print("\(param.info->geafile.name) \(long( param.process + param.done ) * 100L / long( param.info->geafile.size ))% \r")
124 }
125 else
126 {
127 print("\(param.name) \(long( param.process + param.done ) * 100L / long( param.info->geafile.size ))% \r")
128 }
129 }
130 case $GEAMESS_WRONGVER
131 {
132 switch conrequest( "The file \(param.name) has the unsupported GEA format version (Abort|Ignore)", "Aa|Ii" )
133 {
134 case 0 : return $GEA_ABORT
135 case 1 : return $GEA_IGNORE
136 }
137 }
138 case $GEAMESS_GETVOLUME
139 {
140 /* uint disktype
141 drivename.substr( diskname, 0, 3 )
142 disktype = getdrivetype( drivename )
143 if disktype == $DRIVE_REMOVABLE || disktype == $DRIVE_CDROM
144 {
145 if this.mess( $GEAMESS_GETVOLUME, %{ diskname, num + 1 }) ==
146 $GEA_ABORT : return 0
147 }*/
148 return $GEA_OK
149 }
150 }
151 if code < $GEAERR_LAST : return 0
152 return 1
153 }
154
155 func test<main>
156 {
157 geaeinit geai
158 geae gpack
159 ffind fd
160 geacomp gc
161
162 geai.userfunc = &userfunc
163 geai.flags |= $GEAI_IGNORECOPY
164 geai.volsize = 100L * 1024L//0L//0x50000L
165 geai.pattern = "test.g%02u"
166 gpack.create( "c:\\setups\\test.gea", geai )
167 fd.init( "c:\\temp\\g\\*.*", $FIND_FILE )
168 gc.compmethod = $GEA_STORE//$GEA_PPMD//$GEA_LZGE//$GEA_PPMD
169 gc.order = 1
170 gc.solid = 1
171 // gc.password = "ok"
172 foreach cur, fd
173 {
174 gpack.add( cur.fullname, gc )
175 }
176 gpack.close()
177
178 geadinit geadi
179 gead gunpack
180 uint i
181
182 geadi.userfunc = &userfunc
183 geadi.geaoff = 0//0x18963
184 print("Test GEA archive ================================\n")
185 gunpack.open( "c:\\setups\\test.gea", geadi )
186 // gunpack.open( "c:\\setups\\disk1.pak", geadi )
187 fornum i, *gunpack.fileinfo
188 {
189 if !gunpack.test( i ) : print("Error testing...\n")
190 }
191
192 congetch( "Press any key..." )
193 }
Редактировать