0
|
1 // This file is a part of the Relic Tools and is copyright 2006-2018 IBBoard.
|
|
2 //
|
|
3 // The file and the library/program it is in are licensed under the GNU GPL license, either version 3 of the License or (at your option) any later version. Please see COPYING for more information and the full license.
|
|
4
|
|
5 using System;
|
|
6 using System.IO;
|
|
7 using System.Collections;
|
|
8
|
|
9 namespace IBBoard.Relic.RelicTools
|
|
10 {
|
|
11 /// <summary>
|
|
12 /// Summary description for SgaArchive.
|
|
13 /// </summary>
|
|
14 public class SgaArchive
|
|
15 {
|
|
16 private string path = "";
|
|
17 private readonly Hashtable attrib;
|
|
18 private SgaReader sr = null;
|
|
19 private SgaFolder root = null;
|
|
20 private FileInfo file = null;
|
|
21
|
|
22 /// <summary>
|
|
23 ///
|
|
24 /// </summary>
|
|
25 /// <param name="pathIn"></param>
|
|
26 public SgaArchive(string pathIn)
|
|
27 {
|
|
28 path = pathIn;
|
|
29 file = new FileInfo(this.path);
|
|
30 sr = new SgaReader(path);
|
|
31 sr.Archive = this;
|
|
32 attrib = sr.ReadHeaders();
|
|
33 root = sr.ReadFolders((long)attrib["DirOffset"], (long)attrib["ItemOffset"], attrib["TocAlias"].ToString());
|
|
34 root.ParentArchive = this;
|
|
35 }
|
|
36
|
|
37 /// <summary>
|
|
38 ///
|
|
39 /// </summary>
|
|
40 public SgaReader ArchiveReader
|
|
41 {
|
|
42 get{ return sr; }
|
|
43 }
|
|
44
|
|
45 public string Name
|
|
46 {
|
|
47 get{ return file.Name; }
|
|
48 }
|
|
49
|
|
50 public SgaFolder Root
|
|
51 {
|
|
52 get{return root;}
|
|
53 }
|
|
54
|
|
55 public int Version
|
|
56 {
|
|
57 get { return (int)(long)attrib["Version"]; }
|
|
58 }
|
|
59
|
|
60 /// <summary>
|
|
61 ///
|
|
62 /// </summary>
|
|
63 public Hashtable Attributes
|
|
64 {
|
|
65 get{ return attrib; }
|
|
66 }
|
|
67
|
|
68 public string DefaultPath
|
|
69 {
|
|
70 get{ return file.DirectoryName+Path.DirectorySeparatorChar+attrib["TocAlias"]; }
|
|
71 }
|
|
72
|
|
73 public string BasePath
|
|
74 {
|
|
75 get{ return file.DirectoryName; }
|
|
76 }
|
|
77
|
|
78 /// <summary>
|
|
79 ///
|
|
80 /// </summary>
|
|
81 public bool ExtractAll()
|
|
82 {
|
|
83 return ExtractAll(this.DefaultPath);
|
|
84 }
|
|
85
|
|
86 /// <summary>
|
|
87 ///
|
|
88 /// </summary>
|
|
89 /// <param name="overwrite"></param>
|
|
90 public bool ExtractAll(bool overwrite)
|
|
91 {
|
|
92 return ExtractAll(this.DefaultPath, overwrite);
|
|
93 }
|
|
94
|
|
95 /// <summary>
|
|
96 ///
|
|
97 /// </summary>
|
|
98 /// <param name="destination"></param>
|
|
99 public bool ExtractAll(string destination)
|
|
100 {
|
|
101 return ExtractAll(destination, false);
|
|
102 }
|
|
103
|
|
104 /// <summary>
|
|
105 ///
|
|
106 /// </summary>
|
|
107 /// <param name="desintation"></param>
|
|
108 /// <param name="overwrite"></param>
|
|
109 public bool ExtractAll(string desintation, bool overwrite)
|
|
110 {
|
|
111 return ExtractFolder("",desintation, true, overwrite);
|
|
112 }
|
|
113
|
|
114 /// <summary>
|
|
115 /// Extracts the specified folder to it's default location
|
|
116 /// </summary>
|
|
117 /// <param name="folderPath">The path of the folder to extract</param>
|
|
118 public bool ExtractFolder(string folderPath)
|
|
119 {
|
|
120 folderPath = this.TrimPath(folderPath);
|
|
121
|
|
122 return ExtractFolder(folderPath, this.DefaultPath+"\\"+folderPath);
|
|
123 }
|
|
124
|
|
125 public bool ExtractFolder(string folderPath, string dest)
|
|
126 {
|
|
127 return ExtractFolder(folderPath, dest, false);
|
|
128 }
|
|
129
|
|
130 /// <summary>
|
|
131 ///
|
|
132 /// </summary>
|
|
133 /// <param name="folderPath"></param>
|
|
134 /// <param name="recursive"></param>
|
|
135 public bool ExtractFolder(string folderPath, bool recursive)
|
|
136 {
|
|
137 folderPath = this.TrimPath(folderPath);
|
|
138
|
|
139 return ExtractFolder(folderPath, this.DefaultPath+"\\"+folderPath, recursive);
|
|
140 }
|
|
141
|
|
142 public bool ExtractFolder(string folderPath, bool recursive, bool overwrite)
|
|
143 {
|
|
144 folderPath = this.TrimPath(folderPath);
|
|
145
|
|
146 return ExtractFolder(folderPath, this.DefaultPath+"\\"+folderPath, recursive, overwrite);
|
|
147 }
|
|
148
|
|
149
|
|
150 /// <summary>
|
|
151 ///
|
|
152 /// </summary>
|
|
153 /// <param name="folderPath"></param>
|
|
154 /// <param name="destination"></param>
|
|
155 public bool ExtractFolder(string folderPath, string find, string replace)
|
|
156 {
|
|
157 folderPath = this.TrimPath(folderPath);
|
|
158
|
|
159 return ExtractFolder(folderPath, this.DefaultPath+"\\"+folderPath, find, replace);
|
|
160 }
|
|
161
|
|
162 public bool ExtractFolder(string folderPath, string find, string replace, bool recursive)
|
|
163 {
|
|
164 folderPath = this.TrimPath(folderPath);
|
|
165
|
|
166 return ExtractFolder(folderPath, this.DefaultPath+"\\"+folderPath, recursive, false);
|
|
167 }
|
|
168
|
|
169 public bool ExtractFolder(string folderPath, string find, string replace, bool recursive, bool overwrite)
|
|
170 {
|
|
171 folderPath = this.TrimPath(folderPath);
|
|
172
|
|
173 return ExtractFolder(folderPath, this.DefaultPath+"\\"+folderPath, "", "", recursive, overwrite);
|
|
174 }
|
|
175
|
|
176 public bool ExtractFolder(string folderPath, string[] find, string[] replace)
|
|
177 {
|
|
178 folderPath = this.TrimPath(folderPath);
|
|
179
|
|
180 return ExtractFolder(folderPath, this.DefaultPath+"\\"+folderPath, find, replace, false);
|
|
181 }
|
|
182
|
|
183 public bool ExtractFolder(string folderPath, string[] find, string[] replace, bool recursive)
|
|
184 {
|
|
185 folderPath = this.TrimPath(folderPath);
|
|
186
|
|
187 return ExtractFolder(folderPath, this.DefaultPath+"\\"+folderPath, find, replace, recursive, false);
|
|
188 }
|
|
189
|
|
190 public bool ExtractFolder(string folderPath, string[] find, string[] replace, bool recursive, bool overwrite)
|
|
191 {
|
|
192 folderPath = this.TrimPath(folderPath);
|
|
193
|
|
194 return ExtractFolder(folderPath, this.DefaultPath+"\\"+folderPath, find, replace, recursive, overwrite);
|
|
195 }
|
|
196
|
|
197 /// <summary>
|
|
198 ///
|
|
199 /// </summary>
|
|
200 /// <param name="folderPath"></param>
|
|
201 /// <param name="destination"></param>
|
|
202 /// <param name="recursive"></param>
|
|
203 public bool ExtractFolder(string folderPath, string destination, bool recursive)
|
|
204 {
|
|
205 return ExtractFolder(folderPath, destination, recursive, false);
|
|
206 }
|
|
207
|
|
208 public bool ExtractFolder(string folderPath, string destination, bool recursive, bool overwrite)
|
|
209 {
|
|
210 return ExtractFolder(folderPath, destination, "", "", recursive, overwrite);
|
|
211 }
|
|
212
|
|
213 public bool ExtractFolder(string folderPath, string destination, string find, string replace)
|
|
214 {
|
|
215 return ExtractFolder(folderPath, destination, find, replace, false);
|
|
216 }
|
|
217
|
|
218 public bool ExtractFolder(string folderPath, string destination, string[] find, string[] replace)
|
|
219 {
|
|
220 return ExtractFolder(folderPath, destination, find, replace, false);
|
|
221 }
|
|
222
|
|
223 public bool ExtractFolder(string folderPath, string destination, string find, string replace, bool recursive)
|
|
224 {
|
|
225 return ExtractFolder(folderPath, destination, find, replace, recursive, false);
|
|
226 }
|
|
227
|
|
228 public bool ExtractFolder(string folderPath, string destination, string[] find, string[] replace, bool recursive)
|
|
229 {
|
|
230 return ExtractFolder(folderPath, destination, find, replace, recursive, false);
|
|
231 }
|
|
232
|
|
233 public bool ExtractFolder(string folderPath, string destination, string find, string replace, bool recursive, bool overwrite)
|
|
234 {
|
|
235 return ExtractFolder(folderPath, destination, new string[]{find}, new string[]{replace}, recursive, overwrite);
|
|
236 }
|
|
237
|
|
238 public bool ExtractFolder(string folderPath, string destination, string[] find, string[] replace, bool recursive, bool overwrite)
|
|
239 {
|
|
240 destination = destination.Replace('\\', Constants.DirectoryChar);
|
|
241 folderPath = folderPath.TrimEnd(Constants.DirectoryChar);
|
|
242 folderPath = TrimPath(folderPath);
|
|
243
|
|
244 SgaFolder container = root.DigFor(folderPath);
|
|
245 if (container!=null)
|
|
246 {
|
|
247 return container.ExtractAll(destination, find, replace, recursive, overwrite);
|
|
248 }
|
|
249 else
|
|
250 {
|
|
251 ExtractFolderFail(container, "path not found");
|
|
252 return false;
|
|
253 }
|
|
254 }
|
|
255
|
|
256 public bool ExtractType(string ext)
|
|
257 {
|
|
258 FileInfo file = new FileInfo(this.path);
|
|
259 return ExtractType(ext, "", this.DefaultPath, true);
|
|
260 }
|
|
261
|
|
262 public bool ExtractType(string ext, bool overwrite)
|
|
263 {
|
|
264 FileInfo file = new FileInfo(this.path);
|
|
265 return ExtractType(ext, "", this.DefaultPath, true, overwrite);
|
|
266 }
|
|
267
|
|
268 public bool ExtractType(string ext, string folderPath)
|
|
269 {
|
|
270 folderPath = this.TrimPath(folderPath);
|
|
271
|
|
272 return ExtractType(ext, folderPath, this.DefaultPath+"\\"+folderPath);
|
|
273 }
|
|
274
|
|
275 public bool ExtractType(string ext, string folderPath, bool recursive)
|
|
276 {
|
|
277 folderPath = this.TrimPath(folderPath);
|
|
278
|
|
279 return ExtractType(ext, folderPath, this.DefaultPath+"\\"+folderPath, recursive);
|
|
280 }
|
|
281
|
|
282 public bool ExtractType(string ext, string folderPath, bool recursive, bool overwrite)
|
|
283 {
|
|
284 folderPath = this.TrimPath(folderPath);
|
|
285
|
|
286 return ExtractType(ext, folderPath, this.DefaultPath+"\\"+folderPath, recursive, overwrite);
|
|
287 }
|
|
288
|
|
289 public bool ExtractType(string ext, string folderPath, string destination)
|
|
290 {
|
|
291 return ExtractType(ext, folderPath, destination, false);
|
|
292 }
|
|
293
|
|
294 public bool ExtractType(string ext, string folderPath, string destination, bool recursive)
|
|
295 {
|
|
296 return ExtractType(ext, folderPath, destination, recursive, false);
|
|
297 }
|
|
298
|
|
299 public bool ExtractType(string ext, string folderPath, string destination, bool recursive, bool overwrite)
|
|
300 {
|
|
301 return ExtractType(ext, folderPath, destination, "", "", recursive, overwrite);
|
|
302 }
|
|
303
|
|
304 public bool ExtractType(string ext, string folderPath, string find, string replace)
|
|
305 {
|
|
306 folderPath = this.TrimPath(folderPath);
|
|
307
|
|
308 return ExtractType(ext, folderPath, this.DefaultPath+"\\"+folderPath, find, replace, false);
|
|
309 }
|
|
310
|
|
311 public bool ExtractType(string ext, string folderPath, string find, string replace, bool recursive)
|
|
312 {
|
|
313 folderPath = this.TrimPath(folderPath);
|
|
314
|
|
315 return ExtractType(ext, folderPath, this.DefaultPath+"\\"+folderPath, find, replace, recursive, false);
|
|
316 }
|
|
317
|
|
318 public bool ExtractType(string ext, string folderPath, string find, string replace, bool recursive, bool overwrite)
|
|
319 {
|
|
320 folderPath = this.TrimPath(folderPath);
|
|
321
|
|
322 return ExtractType(ext, folderPath, this.DefaultPath+"\\"+folderPath, find, replace, recursive, overwrite);
|
|
323 }
|
|
324
|
|
325 public bool ExtractType(string ext, string folderPath, string[] find, string[] replace)
|
|
326 {
|
|
327 folderPath = this.TrimPath(folderPath);
|
|
328
|
|
329 return ExtractType(ext, folderPath, this.DefaultPath+"\\"+folderPath, find, replace, false);
|
|
330 }
|
|
331
|
|
332 public bool ExtractType(string ext, string folderPath, string[] find, string[] replace, bool recursive)
|
|
333 {
|
|
334 folderPath = this.TrimPath(folderPath);
|
|
335
|
|
336 return ExtractType(ext, folderPath, this.DefaultPath+"\\"+folderPath, find, replace, recursive, false);
|
|
337 }
|
|
338
|
|
339 public bool ExtractType(string ext, string folderPath, string[] find, string[] replace, bool recursive, bool overwrite)
|
|
340 {
|
|
341 folderPath = this.TrimPath(folderPath);
|
|
342
|
|
343 return ExtractType(ext, folderPath, this.DefaultPath+"\\"+folderPath, find, replace, recursive, overwrite);
|
|
344 }
|
|
345
|
|
346 public bool ExtractType(string ext, string folderPath, string destination, string[] find, string[] replace)
|
|
347 {
|
|
348 return ExtractType(ext, folderPath, destination, find, replace, false, false);
|
|
349 }
|
|
350
|
|
351 public bool ExtractType(string ext, string folderPath, string destination, string find, string replace)
|
|
352 {
|
|
353 return ExtractType(ext, folderPath, destination, find, replace, false, false);
|
|
354 }
|
|
355
|
|
356 public bool ExtractType(string ext, string folderPath, string destination, string[] find, string[] replace, bool recursive)
|
|
357 {
|
|
358 return ExtractType(ext, folderPath, destination, find, replace, recursive, false);
|
|
359 }
|
|
360
|
|
361 public bool ExtractType(string ext, string folderPath, string destination, string find, string replace, bool recursive)
|
|
362 {
|
|
363 return ExtractType(ext, folderPath, destination, find, replace, recursive, false);
|
|
364 }
|
|
365
|
|
366 public bool ExtractType(string ext, string folderPath, string destination, string find, string replace, bool recursive, bool overwrite)
|
|
367 {
|
|
368 return ExtractType(ext, folderPath, destination, new string[]{find}, new string[]{replace}, recursive, overwrite);
|
|
369 }
|
|
370
|
|
371 public bool ExtractType(string ext, string folderPath, string destination, string[] find, string[] replace, bool recursive, bool overwrite)
|
|
372 {
|
|
373 folderPath = this.TrimPath(folderPath);
|
|
374
|
|
375 SgaFolder container = root.DigFor(folderPath);
|
|
376
|
|
377 if (container!=null)
|
|
378 {
|
|
379 return container.ExtractType(ext,destination, find, replace, recursive, overwrite);
|
|
380 }
|
|
381 else
|
|
382 {
|
|
383 ExtractFolderFail(null, "path not found");
|
|
384 return false;
|
|
385 }
|
|
386 }
|
|
387
|
|
388
|
|
389 public bool Extract(string filePath)
|
|
390 {
|
|
391 filePath = this.TrimPath(filePath);
|
|
392
|
|
393 int lastSlash = filePath.LastIndexOf("\\");
|
|
394 int lastDot = filePath.LastIndexOf('.');
|
|
395 string folderPath = "";
|
|
396
|
|
397 if (lastDot==-1)
|
|
398 {
|
|
399 //Someone stole our dot!
|
|
400 ExtractFileFail(null, "Filename '"+filePath+"'did not contain an extension");
|
|
401 return false;
|
|
402 }
|
|
403 else
|
|
404 {
|
|
405 folderPath = filePath.Substring(0,lastSlash);
|
|
406 }
|
|
407
|
|
408 return Extract(filePath, this.DefaultPath+"\\"+folderPath, false);
|
|
409 }
|
|
410
|
|
411 public bool Extract(string filePath, bool overwrite)
|
|
412 {
|
|
413 filePath = this.TrimPath(filePath);
|
|
414
|
|
415 int lastSlash = filePath.LastIndexOf("\\");
|
|
416 int lastDot = filePath.LastIndexOf('.');
|
|
417 string folderPath = "";
|
|
418
|
|
419 if (lastDot==-1)
|
|
420 {
|
|
421 //Someone stole our dot!
|
|
422 ExtractFileFail(null, "Filename '"+filePath+"'did not contain an extension");
|
|
423 return false;
|
|
424 }
|
|
425 else if (lastSlash>=0)
|
|
426 {
|
|
427 folderPath = filePath.Substring(0,lastSlash);
|
|
428 }
|
|
429
|
|
430 return Extract(filePath, this.DefaultPath+"\\"+folderPath, overwrite);
|
|
431 }
|
|
432
|
|
433 public bool Extract(string filePath, string find, string replace)
|
|
434 {
|
|
435 filePath = this.TrimPath(filePath);
|
|
436
|
|
437 int lastSlash = filePath.LastIndexOf("\\");
|
|
438 int lastDot = filePath.LastIndexOf('.');
|
|
439 string folderPath = "";
|
|
440
|
|
441 if (lastDot==-1)
|
|
442 {
|
|
443 //Someone stole our dot!
|
|
444 ExtractFileFail(null, "Filename '"+filePath+"'did not contain an extension");
|
|
445 return false;
|
|
446 }
|
|
447 else
|
|
448 {
|
|
449 folderPath = filePath.Substring(0,lastSlash);
|
|
450 }
|
|
451
|
|
452 return Extract(filePath, this.DefaultPath+"\\"+folderPath, find, replace);
|
|
453 }
|
|
454
|
|
455 public bool Extract(string filePath, string find, string replace, bool overwrite)
|
|
456 {
|
|
457 filePath = this.TrimPath(filePath);
|
|
458
|
|
459 int lastSlash = filePath.LastIndexOf("\\");
|
|
460 int lastDot = filePath.LastIndexOf('.');
|
|
461 string folderPath = "";
|
|
462
|
|
463 if (lastDot==-1)
|
|
464 {
|
|
465 //Someone stole our dot!
|
|
466 ExtractFileFail(null, "Filename '"+filePath+"'did not contain an extension");
|
|
467 return false;
|
|
468 }
|
|
469 else
|
|
470 {
|
|
471 folderPath = filePath.Substring(0,lastSlash);
|
|
472 }
|
|
473
|
|
474 return Extract(filePath, this.DefaultPath+"\\"+folderPath, find, replace, overwrite);
|
|
475 }
|
|
476
|
|
477 public bool Extract(string filePath, string[] find, string[] replace)
|
|
478 {
|
|
479 filePath = this.TrimPath(filePath);
|
|
480
|
|
481 int lastSlash = filePath.LastIndexOf("\\");
|
|
482 int lastDot = filePath.LastIndexOf('.');
|
|
483 string folderPath = "";
|
|
484
|
|
485 if (lastDot==-1)
|
|
486 {
|
|
487 //Someone stole our dot!
|
|
488 ExtractFileFail(null, "Filename '"+filePath+"'did not contain an extension");
|
|
489 return false;
|
|
490 }
|
|
491 else
|
|
492 {
|
|
493 folderPath = filePath.Substring(0,lastSlash);
|
|
494 }
|
|
495
|
|
496 return Extract(filePath, this.DefaultPath+"\\"+folderPath, find, replace, false);
|
|
497 }
|
|
498
|
|
499 public bool Extract(string filePath, string[] find, string[] replace, bool overwrite)
|
|
500 {
|
|
501 filePath = this.TrimPath(filePath);
|
|
502
|
|
503 int lastSlash = filePath.LastIndexOf("\\");
|
|
504 int lastDot = filePath.LastIndexOf('.');
|
|
505 string folderPath = "";
|
|
506
|
|
507 if (lastDot==-1)
|
|
508 {
|
|
509 //Someone stole our dot!
|
|
510 ExtractFileFail(null, "Filename '"+filePath+"' did not contain an extension");
|
|
511 return false;
|
|
512 }
|
|
513 else
|
|
514 {
|
|
515 folderPath = filePath.Substring(0,lastSlash);
|
|
516 }
|
|
517
|
|
518 return Extract(filePath, this.DefaultPath+"\\"+folderPath, find, replace, overwrite);
|
|
519 }
|
|
520
|
|
521 /// <summary>
|
|
522 ///
|
|
523 /// </summary>
|
|
524 /// <param name="filePath"></param>
|
|
525 /// <param name="destination"></param>
|
|
526 public bool Extract(string filePath, string destination)
|
|
527 {
|
|
528 return Extract(filePath, destination,"","", false);
|
|
529 }
|
|
530
|
|
531 public bool Extract(string filePath, string destination, bool overwrite)
|
|
532 {
|
|
533 return Extract(filePath, destination,"","", overwrite);
|
|
534 }
|
|
535
|
|
536 /// <summary>
|
|
537 ///
|
|
538 /// </summary>
|
|
539 /// <param name="filePath"></param>
|
|
540 /// <param name="destination"></param>
|
|
541 /// <param name="find"></param>
|
|
542 /// <param name="replace"></param>
|
|
543 public bool Extract(string filePath, string destination, string find, string replace)
|
|
544 {
|
|
545 return Extract(filePath, destination, new string[]{find}, new string[]{replace});
|
|
546 }
|
|
547
|
|
548 public bool Extract(string filePath, string destination, string find, string replace, bool overwrite)
|
|
549 {
|
|
550 return Extract(filePath, destination, new string[]{find}, new string[]{replace}, overwrite);
|
|
551 }
|
|
552
|
|
553 public bool Extract(string filePath, string destination, string[] find, string[] replace)
|
|
554 {
|
|
555 return Extract(filePath, destination, find, replace, false);
|
|
556 }
|
|
557 public bool Extract(string filePath, string destination, string[] find, string[] replace, bool overwrite)
|
|
558 {
|
|
559
|
|
560 if (destination.EndsWith("\\"))
|
|
561 {
|
|
562 destination = destination.TrimEnd('\\');
|
|
563 }
|
|
564
|
|
565 filePath = this.TrimPath(filePath);
|
|
566
|
|
567 int lastSlash = filePath.LastIndexOf('\\');
|
|
568 string folderPath = "";
|
|
569
|
|
570 if (lastSlash>-1)
|
|
571 {
|
|
572 folderPath = filePath.Substring(0, lastSlash);
|
|
573 }
|
|
574
|
|
575 destination = destination.Replace('\\', Constants.DirectoryChar);
|
|
576
|
|
577 SgaFolder container = root.DigFor(folderPath);
|
|
578
|
|
579 if (container!=null)
|
|
580 {
|
|
581 string fileName = filePath.Substring(filePath.LastIndexOf('\\')+1);
|
|
582 return container.Extract(fileName, destination, find, replace, overwrite);
|
|
583 }
|
|
584 else
|
|
585 {
|
|
586 ExtractFileFail(null, "path not found");
|
|
587 return false;
|
|
588 //throw exception
|
|
589 }
|
|
590 }
|
|
591
|
|
592 /// <summary>
|
|
593 ///
|
|
594 /// </summary>
|
|
595 /// <param name="folderPath"></param>
|
|
596 /// <returns></returns>
|
|
597 public string TrimPath(string folderPath)
|
|
598 {
|
|
599 string temp = folderPath.ToLower();
|
|
600 string start = "\\"+(string)attrib["TocAlias"];
|
|
601
|
|
602 if (temp==start)
|
|
603 {
|
|
604 return "";
|
|
605 }
|
|
606 else if (temp.StartsWith(start))
|
|
607 {
|
|
608 return folderPath.Substring(start.Length+1);
|
|
609 }
|
|
610 else
|
|
611 {
|
|
612 return folderPath;
|
|
613 }
|
|
614 }
|
|
615
|
|
616 public delegate void ExtractionNotification(string type, string name, string message);
|
|
617
|
|
618 public event ExtractionNotification OnExtractFileFail;
|
|
619 public event ExtractionNotification OnExtractFileSuccess;
|
|
620 public event ExtractionNotification OnExtractFolderFail;
|
|
621 public event ExtractionNotification OnExtractFolderSuccess;
|
|
622
|
|
623 public void ExtractFileFail(SgaFile file, string reason)
|
|
624 {
|
|
625 if (OnExtractFileFail!=null)
|
|
626 {
|
|
627 if (file==null)
|
|
628 {
|
|
629 OnExtractFileFail("File", "unknown", reason);
|
|
630 }
|
|
631 else
|
|
632 {
|
|
633 OnExtractFileFail("File", file.Name, reason);
|
|
634 }
|
|
635 }
|
|
636 }
|
|
637
|
|
638 public void ExtractFileSuccess(SgaFile file)
|
|
639 {
|
|
640 if (OnExtractFileSuccess!=null)
|
|
641 {
|
|
642 OnExtractFileSuccess("File", file.Name, "");
|
|
643 }
|
|
644 }
|
|
645
|
|
646 public void ExtractFolderFail(SgaFolder folder, string reason)
|
|
647 {
|
|
648 if (OnExtractFolderFail!=null)
|
|
649 {
|
|
650 if (folder==null)
|
|
651 {
|
|
652 OnExtractFolderFail("Folder", "unknown", reason);
|
|
653 }
|
|
654 else
|
|
655 {
|
|
656 OnExtractFolderFail("Folder", folder.Path, reason);
|
|
657 }
|
|
658 }
|
|
659 }
|
|
660
|
|
661 public void ExtractFolderSuccess(SgaFolder folder)
|
|
662 {
|
|
663 if (OnExtractFolderSuccess!=null)
|
|
664 {
|
|
665 OnExtractFolderSuccess("Folder", folder.Path, "");
|
|
666 }
|
|
667 }
|
|
668 }
|
|
669 } |