-
Notifications
You must be signed in to change notification settings - Fork 10
/
arcview.pas
2127 lines (2034 loc) · 60.3 KB
/
arcview.pas
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
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
{/////////////////////////////////////////////////////////////////////////
//
// Dos Navigator Open Source 1.51.08
// Based on Dos Navigator (C) 1991-99 RIT Research Labs
//
// This programs is free for commercial and non-commercial use as long as
// the following conditions are aheared to.
//
// Copyright remains RIT Research Labs, and as such any Copyright notices
// in the code are not to be removed. If this package is used in a
// product, RIT Research Labs should be given attribution as the RIT Research
// Labs of the parts of the library used. This can be in the form of a textual
// message at program startup or in documentation (online or textual)
// provided with the package.
//
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions are
// met:
//
// 1. Redistributions of source code must retain the copyright
// notice, this list of conditions and the following disclaimer.
// 2. Redistributions in binary form must reproduce the above copyright
// notice, this list of conditions and the following disclaimer in the
// documentation and/or other materials provided with the distribution.
// 3. All advertising materials mentioning features or use of this software
// must display the following acknowledgement:
// "Based on Dos Navigator by RIT Research Labs."
//
// THIS SOFTWARE IS PROVIDED BY RIT RESEARCH LABS "AS IS" AND ANY EXPRESS
// OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
// WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
// DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE FOR
// ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
// DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
// GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
// INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER
// IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
// OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
// ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
//
// The licence and distribution terms for any publically available
// version or derivative of this code cannot be changed. i.e. this code
// cannot simply be copied and put under another distribution licence
// (including the GNU Public Licence).
//
//////////////////////////////////////////////////////////////////////////}
{JO, AK155: 27.11.2002 - ¤®¡ ¢¨«¨ à áªàë⨥ à娢®¢ ¢ ¢¥â¢ì ¯® Ctrl-H}
{JO: 1.12.2002 - ¤®¡ ¢¨« ¯®¨áª ä ©«®¢ ¢ãâਠà娢 }
{$I STDEFINE.INC}
unit ArcView;
interface
uses
Objects, Defines, Objects2, Streams, Views,
FilesCol, DiskInfo,
Drives, Commands, Archiver, FStorage
;
type
PArcDrive = ^TArcDrive;
TArcDrive = object(TDrive)
{Cat: íâ®â ®¡ê¥ªâ ¢ë¥á¥ ¢ ¯« £¨ãî ¬®¤¥«ì; ¨§¬¥ïâì ªà ©¥ ®áâ®à®¦®!}
ArcName: String; {DataCompBoy}
VArcName: String; {JO}
AType: PARJArchive;
Files: PDirStorage;
KillAfterUse: Boolean;
FakeKillAfterUse: Boolean; {¢à¥¬¥ ï ¯ãáâëèª }
ArcDate: LongInt;
ArcSize: TFileSize; {á®åà ïîâáï ¢¬¥áâ¥}
ForceRescan: Boolean;
Password: String;
constructor Init(const AName, VAName: String);
constructor InitCol(PC: PDirStorage; const AName, VAName: String);
constructor Load(var S: TStream);
procedure Store(var S: TStream); virtual;
procedure RereadDirectory(S: String); virtual; {DataCompBoy}
procedure KillUse; virtual;
function ReadArchive: Boolean;
procedure lChDir(ADir: String); virtual; {DataCompBoy}
function GetDir: String; virtual;
function GetDirectory(
const FileMask: String;
var TotalInfo: TSize): PFilesCollection; virtual;
function Exec(Prg, Cmd: String; Lst: AnsiString; B: Boolean): Boolean;
{JO: ¢ë¤¥«¨« ᯨ᮪ ä ©«®¢ ¢ ª®¬ ¤®© áâப¥ ¨«¨ ¯ãâì ª }
{ ä ©«ã-ᯨáªã ¢ ®â¤¥«ìë© ¯ à ¬¥âà Lst; }
{ ¯ à ¬¥âà B ¤®«¦¥ ¡ëâì False, ¥á«¨ ¨á¯®«ì§ã¥¬ }
{ ä ©«-ᯨ᮪ ¨«¨ à § à娢¨à㥬 ®¤¨®çë© ä ©« ¥ ¯à¨¡¥£ ï ª ᯨáªã }
{ ¨ True, ¥á«¨ ¨á¯®«ì§ã¥¬ ᯨ᮪ ¢ ª®¬ ¤®© áâப¥ }
procedure UseFile(P: PFileRec; Command: Word); virtual;
{DataCompBoy}
function MakeListFile(PC: PCollection; UseUnp: Boolean;
var B: Boolean): AnsiString;
{JO: ¯ à ¬¥âà UseUnp 㪠§ë¢ ¥â, ¡ã¤¥¬ ¨á¯®«ì§®¢ âì ¯®«ãç¥ë© }
{ ᯨ᮪ ä ©«®¢ ¤«ï à ᯠª®¢é¨ª (True), ¨«¨ ¯ ª®¢é¨ª (False); }
{ ¯¥à¥¬¥ ï ‚ ¢®§¢à é ¥â, ¡ë« «¨ ᮧ¤ 䯨᮪ ¢ }
{ ª®¬ ¤®© áâப¥ (True) ¨«¨ ¢ ä ©«¥-ᯨ᪥ (False) }
procedure CopyFiles(AFiles: PCollection; Own: PView;
MoveMode: Boolean); virtual;
procedure CopyFilesInto(AFiles: PCollection; Own: PView;
MoveMode: Boolean); virtual;
procedure EraseFiles(AFiles: PCollection); virtual;
{procedure GetDown(var B; C: Word; P: PFileRec); virtual;}
{DataCompBoy}
function GetRealName: String; virtual;
function GetInternalName: String; virtual;
procedure HandleCommand(Command: Word; InfoPtr: Pointer); virtual;
procedure MakeDir; virtual;
function isUp: Boolean; virtual;
procedure ChangeUp(var S: String); virtual;
procedure ChangeRoot; virtual;
procedure ExtractFiles(AFiles: PCollection; ExtrDir: String;
Own: PView; Options: Byte); {DataCompBoy}
procedure GetFreeSpace(var S: String); virtual;
procedure GetDirInfo(var B: TDiskInfoRec); virtual;
function GetFullFlags: Word; virtual;
procedure GetDirLength(PF: PFileRec); virtual; {DataCompBoy}
destructor Done; virtual;
procedure StdMsg4;
function OpenDirectory(const Dir: String;
PutDirs: Boolean): PDrive; virtual;
procedure DrvFindFile(FC: PFilesCollection); virtual;
procedure ReadDescrptions(FilesC: PFilesCollection); virtual;
function GetDriveLetter: Char; virtual;
end;
function ArcViewer(AName, VAName: String): Boolean;
{DataCompBoy}
procedure StdMsg(MsgNo: Byte);
const
ArcPasw: String[32] = '';
type
PFInfo = ^TFInfo;
TFInfo = record
FName: String;
USize: LongInt;
PSize: LongInt;
Date: LongInt;
Attr: Byte;
Last: Byte;
{ 0 - not last }
{ 1 - archive end }
{ 2 - broken arc }
end;
implementation
uses
VpSysLow, Eraser,
Menus, DNApp, Messages, Dialogs, Gauge, FileCopy, Memory, Startup,
{$IFDEF ARVID}Arvid, {$ENDIF}xTime, VideoMan, DnExec, FileFind
, UserMenu {JO: ¤«ï áªàë¢ ¨ï ¯ ¥«¥© ¯à¨ à § à娢¨à®¢ ¨¨ }
, archZip {JO: ¤«ï CentralDirRecPresent}
, Events {AK155 ¤«ï LongWorkBegin - LongWorkEnd}
, PDSetup, FlPanelX, fnotify, Drivers
, Lfnvp, Files, Tree, Dos, Histries, HistList, FlPanel
, Advance, Advance1, Advance2, ArchDet
, archRAR, archACE
;
const
LowMemSize = $4000; {Local setting}
procedure CheckSlashDot(var S: String);{piwamoto}
begin
if ((S[Length(S)] <> '.') and (S[Length(S)-1] <> '/')) then // slash change by unxed
{directory name '.' bugfix by piwamoto}
While (PosChar(S[Length(S)], './') > 0) do SetLength(S, Length(S)-1); // slash change by unxed
end;
function MaxAvail: LongInt;
begin
MaxAvail := MemAdjust(System.MaxAvail);
end;
procedure StdMsg(MsgNo: Byte);
begin
Application^.Redraw;
case MsgNo of
1:
ErrMsg(dlArcMsg1);
4:
MessageBox(GetString(dlArcMsg4)+''''+
{$IFDEF RecodeWhenDraw}CharToOemStr {$ENDIF}(Cut(ArcFileName,
40))+'''', nil, mfOKButton or mfError);
5:
Msg(dlArcMsg5, nil, mfOKButton or mfInformation);
6:
if MsgHelpCtx <> 0 then
MessageBox(GetString(dlArcMsg6)+GetString(dlPressF1),
nil, mfOKButton or mfError)
else
MessageBox(GetString(dlArcMsg6), nil, mfOKButton or mfError);
7:
Msg(dlArcMsg7, nil, mfOKButton or mfInformation);
end {case};
end;
procedure TArcDrive.StdMsg4;
begin
if TempFile <> '' then
TempFile := '';
StdMsg(4);
Abort := True;
end;
{-DataCompBoy-}
constructor TArcDrive.Init;
var
SR: lSearchRec;
I: Integer;
xt, Q: String;
begin
TObject.Init;
I := PosChar(':', Copy(VAName, 3, MaxStringLength))+2;
if I > 2 then
VArcName := lFExpand(Copy(VAName, 1, I-1))
else
VArcName := lFExpand(VAName);
I := PosChar(':', Copy(AName, 3, MaxStringLength))+2;
if I > 2 then
begin
Q := Copy(AName, I+1, MaxStringLength);
if Q[Length(Q)] in ['\', '/'] then
SetLength(Q, Length(Q)-1);
ArcName := lFExpand(Copy(AName, 1, I-1));
end
else
begin
ArcName := lFExpand(AName);
Q := '/'; // slash change by unxed
end;
{lFSplit(ArcName, FreeStr, Nm, Xt);
if Xt = '' then AddStr(ArcName, '.');}
xt := GetExt(ArcName);
if ( (xt = '') or (xt = '.')) and (ArcName[Length(ArcName)] <> '.')
then
ArcName := ArcName+'.';
lFindFirst(ArcName, AnyFileDir, SR); {JO}
lFindClose(SR);
if DosError <> 0 then
begin
ArcFileName := ArcName;
VArcFileName := VArcName;
StdMsg4;
lFindClose(SR);
Fail
end;
DriveType := dtArc;
ColAllowed := PanelFileColAllowed[pcArc];
if not ReadArchive or (Files = nil) then
begin
Done;
Fail;
end;
KillAfterUse := TempFile <> '';
TempFile := '';
Password := '';
{lFindClose(SR);}
lChDir(Q);
AddToDirectoryHistory(ArcName+':'+CurDir, Integer(DriveType));
end { TArcDrive.Init };
{-DataCompBoy-}
{-DataCompBoy-}
constructor TArcDrive.InitCol;
var
SR: lSearchRec;
begin
TObject.Init;
ArcName := lFExpand(AName);
{VArcName := lFExpand(VAName);}
lFindFirst(ArcName, AnyFileDir, SR); {JO}
ArcDate := SR.SR.Time;
ArcSize := SR.SR.Size;
lFindClose(SR);
DriveType := dtArc;
Files := PC;
if (Files = nil) then
Fail;
KillAfterUse := TempFile <> '';
TempFile := '';
Password := '';
if ExistFile(ArcName) then
New(ArcFile, Init(ArcName, stOpenRead, ArcBufSize))
else
ArcFile := nil;
ArcFileName := ArcName;
VArcFileName := VArcName;
if (ArcFile = nil) or (ArcFile^.Status <> stOK) then
begin
StdMsg(4);
Dispose(ArcFile, Done);
ArcFile := nil;
if Files <> nil then
begin
Dispose(Files, Done);
Files := nil
end;
Fail;
end;
SkipSFX;
AType := DetectArchive;
FreeObject(ArcFile);
end { TArcDrive.InitCol };
{-DataCompBoy-}
{-DataCompBoy-}
constructor TArcDrive.Load;
var
SR: lSearchRec;
label
Failure;
begin
inherited Load(S);
S.ReadStrV(ArcName);
{S.Read(ArcName[0],1); S.Read(ArcName[1],Length(ArcName));}
{Cat}
S.ReadStrV(VArcName);
{S.Read(VArcName[0],1); S.Read(VArcName[1],Length(VArcName));}
{/Cat}
S.Read(FakeKillAfterUse, 1);
{¢à¥¬¥®}
KillAfterUse := False;
S.ReadStrV(Password);
{S.Read(Password[0],1); S.Read(Password[1],Length(Password));}
S.Read(ArcDate, SizeOf(ArcDate)+SizeOf(ArcSize));
ForceRescan := False;
DriveType := dtArc;
ArcFileName := ArcName;
VArcFileName := VArcName;
Files := PDirStorage(S.Get);
{ AK155 „ ë¥ ® ä ©« å ¤® ¯à®ç¨â âì ¨§ ¯®â®ª ¥§ ¢¨á¨®
®â ⮣®, ¡ã¤¥â «¨ ©¤¥ á ¬ à娢 ¨ ¤® «¨ ¥£® ¯¥à¥ç¨âë¢ âì,
¨ ç¥ á®¡ìñâáï ¤ «ì¥©è¥¥ ç⥨¥ ¯®â®ª }
lFindFirst(ArcName, AnyFileDir, SR); {JO}
lFindClose(SR);
if DosError <> 0 then
goto Failure;
if (ArcDate <> SR.SR.Time) or (ArcSize <> SR.SR.Size) then
begin { à娢 ¨§¬¥¨«áï, ¤® ¥£® ¯¥à¥ç¨âë¢ âì § ®¢®}
CurDir := '/'; // slash change by unxed
ReadArchive;
end
else
begin
New(ArcFile, Init(ArcName, stOpenRead, ArcBufSize));
if (ArcFile = nil) or (ArcFile^.Status <> stOK) then
begin
Dispose(ArcFile, Done);
ArcFile := nil;
goto Failure;
end;
SkipSFX;
AType := DetectArchive;
FreeObject(ArcFile);
if AType = nil then
begin
Failure:
StdMsg(4);
if Files <> nil then
Dispose(Files, Done);
Files := nil;
S.Read(ForceRescan, 1);
Fail;
end;
end;
S.Read(ForceRescan, 1);
end { TArcDrive.Load };
{-DataCompBoy-}
procedure TArcDrive.KillUse;
begin
if Prev <> nil then
Prev^.KillUse;
if KillAfterUse then
EraseTempFile(ArcName);
end;
procedure TArcDrive.Store;
begin
inherited Store(S);
S.WriteStr(@ArcName); {S.Write(ArcName[0],1 + Length(ArcName));}
S.WriteStr(@VArcName); {S.Write(VArcName[0],1 + Length(VArcName));}
{Cat}
S.Write(KillAfterUse, 1);
S.WriteStr(@Password); {S.Write(Password[0],1 + Length(Password));}
S.Write(ArcDate, SizeOf(ArcDate)+SizeOf(ArcSize));
S.Put(Files);
S.Write(ForceRescan, 1);
end;
destructor TArcDrive.Done;
begin
if Files <> nil then
Dispose(Files, Done);
Files := nil;
if AType <> nil then
Dispose(AType, Done);
AType := nil;
inherited Done;
end;
{-DataCompBoy-}
function TArcDrive.ReadArchive;
var
PF: PArcFile;
P: PWhileView;
R: TRect;
Ln: TFileSize;
Cancel: Boolean;
T: TEventTimer;
SR: lSearchRec;
begin
{AK155 26-11-2002 ¥à¥ç¨âë¢ ¥¬ à娢 ⮣¤ ¨ ⮫쪮 ⮣¤ , ª®£¤
ã ¥£® ¨§¬¥¨« áì ¤ â /¢à¥¬ï ¨«¨ ¤«¨ }
lFindFirst(ArcName, AnyFileDir, SR);
lFindClose(SR);
if (ArcDate = SR.SR.Time) and (ArcSize = SR.SR.Size) then
begin
ReadArchive := True;
Exit;
end;
ArcDate := SR.SR.Time;
ArcSize := SR.SR.Size;
{/AK155}
CtrlBreakHit := False;
ReadArchive := False;
New(ArcFile, Init(ArcName, stOpenRead, ArcBufSize));
ArcFileName := ArcName;
VArcFileName := VArcName;
if (ArcFile = nil) or (ArcFile^.Status <> stOK) then
begin
Dispose(ArcFile, Done);
ArcFile := nil;
StdMsg4;
Exit;
end;
if Files <> nil then
Dispose(Files, Done);
Files := nil;
Files := nil;
SkipSFX;
if AType <> nil then
Dispose(AType, Done);
AType := nil; {DataCompBoy}
AType := DetectArchive;
if AType = nil then
begin
FreeObject(ArcFile);
Exit;
end;
New(Files, Init);
if Files = nil then
Exit;
P := nil;
R.Assign(1, 1, 30, 10);
{P := WriteMsg(GetString(dlArcReadArc));}
Ln := ArcFile^.GetSize+1;
Cancel := False;
PReader := nil;
Inc(SkyEnabled);
NewTimer(T, 300);
repeat
if (ArcFile <> nil{see TUC2Archive.GetFile}) and TimerExpired(T)
then
begin
LongWorkBegin;
if P = nil then
begin
New(P, Init(R));
PReader := P;
P^.Top := GetString(dlArcReadArc);
P^.Write(1, GetString(dlPercentComplete));
Desktop^.Insert(P);
end;
P^.Write(2,
Copy(Strg(#219, 25 div Trunc(Ln / (ArcFile^.GetPos+1))) +
Strg(#177, 25),
1, 25));
P^.Write(3, ItoS(Files^.Files)+GetString(dlFilesFound));
NewTimer(T, 300);
end;
AType^.GetFile;
if FileInfo.Last = 0 then
begin
//commented by unxed
//Replace('/', '\', FileInfo.FName);
if FileInfo.FName[1] <> '/' then // slash change by unxed
FileInfo.FName := '/'+FileInfo.FName; // slash change by unxed
if FileInfo.Attr and Directory <> 0 then
FileInfo.FName := FileInfo.FName+'/'; // slash change by unxed
if FileInfo.FName[length(FileInfo.FName)] = '/' then // slash change by unxed
FileInfo.Attr := FileInfo.Attr or Directory;
{attribute "Hidden" means "with password"}
Files^.AddFile(FileInfo.FName, FileInfo.USize,
FileInfo.PSize, FileInfo.Date, FileInfo.Attr);
if FileInfo.Attr and Directory <> 0
then
Files^.AddFile(MakeNormName(FileInfo.FName, '..'),
FileInfo.USize, FileInfo.PSize, FileInfo.Date, 0);
if (P <> nil) and TimerExpired(T) then
begin
DispatchEvents(P, Cancel);
if Cancel then
begin
StdMsg(5);
FileInfo.Last := 1;
end;
end;
end;
until (FileInfo.Last > 0) or LowMemory or CtrlBreakHit;
if CtrlBreakHit then
StdMsg(5);
CtrlBreakHit := False;
LongWorkEnd;
Dec(SkyEnabled);
if P <> nil then
P^.Free;
FreeObject(ArcFile);
CDir := '';
if (FileInfo.Last = 2) or
( (AType^.GetID = arcZIP) and not CentralDirRecPresent)
then
StdMsg(6);
ReadArchive := True;
if Files^.Files = 0 then
begin
StdMsg(7);
ReadArchive := False;
end;
end { TArcDrive.ReadArchive };
{-DataCompBoy-}
{-DataCompBoy-}
procedure TArcDrive.lChDir;
var
Dr: String;
Nm: String;
Xt: String;
begin
if ADir = #0 then
Exit;
CheckSlashDot(CurDir);
{ if IsDummyDir(ADir) then}
{piwamoto: we check for '..' only}
{'.' is a valid directory name in archive}
{.tar.gz have a lots of './path/filename'}
if ADir = '..' then
begin
if CurDir <> '' then
while (CurDir <> '')
and (not (CurDir[Length(CurDir)] in ['\', '/']))
do
SetLength(CurDir, Length(CurDir)-1)
else
LFNvp.lChDir(GetPath(ArcName));
Exit;
end;
lFSplit(ADir, Dr, Nm, Xt);
if Xt = '..' then
begin
CurDir := Dr;
while (CurDir <> '') and not (CurDir[Length(CurDir)] in ['\', '/'])
do
SetLength(CurDir, Length(CurDir)-1);
end
else
CurDir := ADir;
MakeNoSlash(CurDir);
if CurDir[1]<>'/' then // slash change by unxed
CurDir:='/'+CurDir; // slash change by unxed
CheckSlashDot(CurDir);
AddToDirectoryHistory(ArcName+':'+CurDir, Integer(DriveType));
end { TArcDrive.lChDir };
{-DataCompBoy-}
{-DataCompBoy-}
function TArcDrive.GetDir;
var
Dr: String;
Nm: String;
Xt: String;
begin
CheckSlashDot(CurDir);
if (Length(CurDir) > 0) and (not (CurDir[1] in ['\', '/'])) then
CurDir := '/'+CurDir; // slash change by unxed
if (Prev <> nil) and (Prev^.DriveType = dtDisk) then
lFSplit(VArcName, Dr, Nm, Xt) {JO}
else
lFSplit(ArcName, Dr, Nm, Xt);
GetDir := AType^.GetSign+Nm+Xt+CurDir;
end;
{-DataCompBoy-}
{-DataCompBoy-}
function TArcDrive.GetDirectory;
var
F: PFileRec;
I, si: LongInt;
AllFiles: Boolean;
AFiles, FD: PFilesCollection;
TTL, TPL: TSize;
_USize, _PSize: TSize;
FR: TFileRec;
OW: Pointer;
Dr: String;
MemReq: LongInt;
MAvail: LongInt;
begin
ReadArchive; {AK155 26-11-2002}
AFiles := New(PFilesCollection, Init($10, $10));
{FD := New(PFilesCollection, Init($40, $10));}
PFilesCollection(AFiles)^.Panel := Panel;
GetDirectory := AFiles;
CheckSlashDot(CurDir);
FD := New(PFilesCollection, Init($40, $10));
TTL := 0;
TPL := 0;
{GetDirectory := AFiles;}AllFiles := (FileMask = x_x)
or (FileMask = '*');
FD^.SortMode := psmLongName; {<sort141.001>}
Files^.ResetPointer('');
{JO: á ç « ®¤¨ p § ®¯p¥¤¥«ï¥¬ ®¡êñ¬ ¤®áâ㯮© ¯ ¬ïâ¨, § ⥬ ¯® 室㠤¥« }
{ ¯®¤áçâ¨âë¢ ¥¬ ᪮«ìª® âp¥¡®¢ ¨ï ¯ ¬ï⨠p áâãâ ¨ ¥ ¯p¥¢ëᨫ¨ «¨ ®¨ }
{ ¤®áâã¯ë© ¨§ ç «ì® ®¡êñ¬ }
MemReq := LowMemSize;
MAvail := MaxAvail;
while not Files^.Last and Files^.GetNextFile and (MAvail > MemReq) do
begin
_USize := Files^.CurFile.Size;
_PSize := Files^.CurFile.CSize;
if (UpStrg(CurDir+'/') = UpStrg(Files^.LastDir)) and // slash change by unxed
(AllFiles or InFilter(Files^.CurFile.Name, FileMask))
then
begin
if Files^.CurFile.Name = '' then
Continue;
if Files^.CurFile.Name = '..' then
Continue;
with Files^.CurFile do
begin
F := NewFileRec(Name, {$IFDEF DualName}GetURZ(Name), {$ENDIF}
_USize, Date, 0, 0, Attr, @CurDir);
Inc(MemReq, SizeOf(TFileRec));
Inc(MemReq, Length(CurDir+Name)+2);
end;
F^.PSize := _PSize;
TTL := TTL+_USize;
TPL := TPL+_PSize;
end
else if (UpStrg(CurDir+'/') = UpStrg(Copy(Files^.LastDir, 1, // slash change by unxed
Length(CurDir)+1)))
then
begin
Dr := Copy(Files^.LastDir, Length(CurDir)+2, MaxStringLength);
I := PosChar('/', Dr); // slash change by unxed
if I = 0 then
I := Length(Dr)+1;
SetLength(Dr, I-1);
if Dr = '' then
Continue;
FillChar(FR, SizeOf(FR), 0);
CopyShortString(Dr, FR.FlName[True]);
FR.Attr := Directory;
I := FD^.IndexOf(@FR);
if I >= 0 then
with PFileRec(FD^.At(I))^ do
begin
Size := Size+_USize;
PSize := PSize+_PSize;
TTL := TTL+_USize;
TPL := TPL+_PSize;
Continue;
end;
F := NewFileRec(Dr, {$IFDEF DualName}GetURZ(Dr), {$ENDIF}_USize,
ArcDate, 0, 0, $80 or Directory, @CurDir);
Inc(MemReq, SizeOf(TFileRec));
Inc(MemReq, Length(CurDir+Dr)+2);
F^.PSize := _PSize;
TTL := TTL+_USize;
TPL := TPL+_PSize;
if FD^.Search(F, si) then
begin
DelFileRec(F);
Continue;
end
{else FD^.Insert(F);}
else
FD^.AtInsert(si, F);
end
else
Continue;
if AFiles^.Search(F, si) then
DelFileRec(F)
{else AFiles^.Insert(F);}
else
AFiles^.AtInsert(si, F);
end;
NoMemory := MAvail <= MemReq;
TotalInfo := TTL;
if CurDir = '' then
OW := @ArcName
else
OW := @CurDir;
(* if TTL > MaxLongInt then F := NewFileRec('..', '..',0, ArcDate, Directory, OW) else
begin
F := NewFileRec({$IFNDEF OS2}'..',{$ENDIF} '..',Round(TTL), ArcDate, Directory, OW);
F^.Attr := $8000 or F^.Attr;
end;
if TPL < MaxLongInt then F^.PSize := Round(TPL); *)
F := NewFileRec('..', {$IFDEF DualName}'..', {$ENDIF} {Round}(TTL), ArcDate,
0, 0, Directory, OW);
F^.Attr := $8000 or F^.Attr;
F^.PSize := {Round}(TPL);
AFiles^.AtInsert(0, F);
FD^.DeleteAll;
Dispose(FD, Done);
end { TArcDrive.GetDirectory };
{-DataCompBoy-}
{-DataCompBoy-}
procedure TArcDrive.UseFile;
var
SS, S, S2, Q: String;
C: Char;
Unp: String;
ATime: LongInt;
ASize: TSize;
AAttr: Word;
RunUnp: Boolean;
{$IFNDEF OS2}
label TryAgain;
{$ENDIF}
begin
TempFile := ''; {-$VOL}
if (Command = cmEditFile) or (Command = cmFileEdit) or
(Command = cmIntEditFile) or (Command = cmIntFileEdit)
then
Exit;
case Command of
cmDBFView:
C := '=';
cmWKZView:
C := '>';
cmTextView, cmViewText:
C := '<';
cmHexView:
C := '|';
cmIntFileView:
C := '-';
else {case}
C := '+';
end {case};
{if not CheckPassword(AF) then Exit;}
S := ' ';
if P^.Attr and Hidden <> 0 then
begin
S := '';
{$IFNDEF OS2}
TryAgain:
{$ENDIF}
if ExecResource(dlgSetPassword, S) <> cmOK then
Exit;
{ Flash >>> }
if CheckForSpaces(S) then
S := ' '+CnvString(AType^.Garble)+S+' '
else
{$IFNDEF OS2}
if AType^.UseLFN then
{$ENDIF}
S := ' '+CnvString(AType^.Garble)+'"'+S+'"'+' '
{$IFNDEF OS2}
else
begin
MessageBox(GetString(dlSpacesInPassword), nil, mfWarning+mfOKButton);
goto TryAgain;
end
{$ENDIF}
;
{ Flash <<< }
end;
SS := MakeNormName(P^.Owner^, P^.FlName[True]);
if SS[1] = '/' then // slash change by unxed
Delete(SS, 1, 1); {DelFC(SS);}
{$IFNDEF OS2}
{
if AType^.UseLFN then
S2 := ArcName
else
S2 := lfGetShortFileName(ArcName);
}
// commented by unxed
if ArcName[Length(ArcName)] = '.' then
S2 := S2+'.';
S := CnvString(AType^.Extract)+' '+S+
CnvString(AType^.ForceMode)+' '+
SquashesName(S2)+' '+SquashesName(SS)+' ';
{$ELSE}
S := CnvString(AType^.Extract)+' '+S+
CnvString(AType^.ForceMode)+' '+
SquashesName(ArcName)+' '+SquashesName(SS)+' ';
{$ENDIF}
{ DelDoubles(' ',S);} {piwamoto: files can have 2 spaces in names}
TempFile := C+MakeNormName(TempDir, P^.FlName[True]);
Q := '|'+GetRealName+':'+MakeNormName(CurDir, P^.FlName[True]);
S2 := Copy(TempFile, 2, MaxStringLength);
if C in ['<', '-', '|', '+'] then
TempFile := TempFile+Q;
GetFTimeSizeAttr(S2, ATime, ASize, AAttr);
RunUnp := not ExistFile(S2) or (PackedDate(P) <> ATime)
or (P^.Size <> ASize);
if RunUnp then
begin
Unp := CnvString(AType^.UnPacker);
if (AType^.GetID = arcRAR) and (PosChar(';', Unp) > 0) then
begin
if PRARArchive(AType)^.VersionToExtr > 20 then
Unp := Copy(Unp, PosChar(';', Unp)+1, 255)
else
Unp := Copy(Unp, 1, PosChar(';', Unp)-1);
end;
{ Flash 21-01-2004
„¨à¥ªâ®à¨î 㦮 § ¯®¬¨ âì ⮬ ¤¨áª¥, £¤¥ 室¨âáï
¢à¥¬¥ë© ª â «®£. € ⮬, £¤¥ «¥¦¨â à娢
á ¯à®á¬ âਢ ¥¬ë¬ ä ©«®¬, ® § ¯®¬¨âáï ¢ «î¡®¬ á«ãç ¥. }
LFNvp.lChDir(Copy(TempDir, 1, 2));
lGetDir(0, DirToChange);
LFNvp.lChDir(TempDir);
Exec(Unp, {$IFDEF RecodeWhenDraw}OemToCharStr {$ENDIF}(S), '', False);
LFNvp.lChDir(DirToChange);
DirToChange := '';
end;
{$IFDEF DPMI32}
if not (AType^.SwapWhenExec and RunUnp) then
begin
{$ENDIF}
TempFileSWP := {$IFDEF RecodeWhenDraw}OemToCharStr {$ENDIF}(TempFile);
TempFile := ''; {-$VOL}
Message(Application, evCommand, cmRetrieveSwp, nil); {JO}
{$IFDEF DPMI32}
end
else
TempFile := ''; {-$VOL}
{$ENDIF}
end { TArcDrive.UseFile };
{-DataCompBoy-}
function TArcDrive.Exec;
var
S: String;
SS1: AnsiString;
SM: Word;
DE: Word;
CmdLineLim, ListLineLim: AWord;
CmdLineOK: Boolean;
I, J: LongInt;
{$IFDEF DPMI32}
T: lText;
EX: String;
I1: Integer;
{$ENDIF}
procedure StdMsg8;
var
L: array[0..1] of LongInt;
ST: String;
begin
Application^.Redraw;
ST := S;
Pointer(L[0]) := @ST;
L[1] := DE;
Msg(dlArcMsg8, @L, mfOKButton or mfError);
end;
{AK155 20/12/2001 …᫨ ¯®¤ Win32 ¯ëâ âìáï ¢ ®â« ¤ç¨ª¥ ¯à®è £ âì
íâã äãªæ¨î, â® ¯®«ãç ¥âáï ¯®« ï ¡«®ª¨à®¢ª ª« ¢¨ âãàë ¨ ¬ëè¨
áà §ã ¢å®¤¥ (¤ ¦¥ á begin ᮩ⨠¥ ¯®«ãç ¥âáï).
â®â íä䥪⠨á祧 ¥â, ¥á«¨ ¯ à ¬¥âà AnsiString § ¬¥¨âì String.
®¤ OS/2 ¢á¥ è £ ¥âáï ¡¥§ ¯à®¡«¥¬. ˆâ¥à¥á®, 祩 íâ® £«îª -
¢¨¤®¢®£® ®â« ¤ç¨ª ¨«¨ ¢¨¤®¢®© RTL? •®à®è®, ¥á«¨ ¯¥à¢®¥. }
begin { TArcDrive.Exec }
Exec := True;
S := Prg+' '+Cmd;
{$IFDEF DPMI32}
if AType^.SwapWhenExec then
begin
if B then
begin
CmdLineLim := 120;
ListLineLim := CmdLineLim-Length(Prg+Cmd)-7;
CmdLineOK := False;
SS1 := Lst; {¤«ï ¯¥à¥áâà 客ª¨}
I1 := 1;
repeat
ClrIO;
EX := SwpDir+'$DN'+ItoS(I1)+'$.BAT';
lAssignText(T, EX);
FileMode := $40;
lResetText(T);
if IOResult <> 0 then
Break;
Close(T.T);
if InOutRes = 0 then
Inc(I1);
until IOResult <> 0;
ClrIO;
lAssignText(T, EX);
lRewriteText(T);
repeat
if Length(Lst) >= ListLineLim then
begin
for I := ListLineLim downto 1 do
if Lst[I] = #$14 then
begin
SS1 := Copy(Lst, 1, I-1);
Delete(Lst, 1, I);
Break;
end;
end
else
begin
SS1 := Lst;
CmdLineOK := True;
end;
for J := 1 to Length(SS1) do
if SS1[J] = #$14 then
SS1[J] := #$20; {JO: § ¬¥ï¥¬ ¢à¥¬¥ë© ᨬ¢®« ¯à®¡¥«ë}
Writeln(T.T, '@'+S+' '+SS1);
until CmdLineOK;
Write(T.T, '@del '+EX);
Close(T.T);
S := EX;
end {if B}
else
if Lst <> '' then
begin
TempFile := SwpDir+'$DN'+ItoS(DNNumber)+'$.LST';
S := S + ' ' + Lst;
end;
Message(Application, evCommand, cmExecString, @S);
end
else {if AType^.SwapWhenExec}
begin
{$ENDIF}
DoneSysError;
DoneEvents;
DoneVideo;
DoneDOSMem;
DoneMemory;
{AK155 ®¤ OS/2, ¢®-¯¥à¢ëå, PATH ®¡ëç® ¥ ã¬¥é ¥âáï
¢ 255 ᨬ¢®«®¢, ¢®-¢â®àëå, ¥â ¯à®¡«¥¬ á ¯ ¬ïâìî,
¢ âà¥âì¨å à娢 â®à ¬®¦¥â ®ª § âìáï „Ž‘®¢ë¬.
’ ª çâ® ¯ã᪠© PATH ¯à®á¬ âਢ ¥â cmd.exe, ¬ë ¥
¡ã¤¥¬ § ¨¬ âìáï á ¬®¤¥ï⥫ì®áâìî }
{AK155, ¤®¯¨á ® ¯®§¦¥, 祬 ª®¬¬¥â ਩ ª OS/2.
®¤ Win32 ⮦¥ ¥ á«¥¤ã¥â § ¨¬ âìáï á ¬®¤¥ï⥫ì®áâìî.
‚®-¯¥à¢ëå, ¬ë ®â¤ ¥¬ ª®á®«ì ¢ ª ª®¬-â® ¥ â ª®¬ á®áâ®ï¨¨,
â ª çâ® ª®á®«ìë© rar ¥ ¬®¦¥â ¢¢®¤¨âì á ª« ¢¨ âãàë.
‚®-¢â®àëå, á⎨«® «¨ à ¡®â âì á ansistring, çâ®¡ë ¯®â®¬ ¢ë§¢ âì
Dos.Exec?}
if B then
begin
{JO: à §¡¨à ¥¬ âã ç áâì ª®¬ ¤®© áâப¨, ª®â®à ï ᮤ¥à¦¨â ᯨ᮪ ä ©«®¢ }
{ ªã᪨ 㤮¡®¢ ਬ®© ¤«ï ª®¬ ¤®£® ¯à®æ¥áá®à ¤«¨ë }
{$IFNDEF DPMI32}
if AType^.ShortCmdLine then
CmdLineLim := {$IFDEF OS2}95 {$ELSE}127 {$ENDIF}
else
CmdLineLim := {$IFDEF OS2}1000 {$ELSE}250 {$ENDIF};
{$ELSE}
CmdLineLim := 95;
{$ENDIF}
ListLineLim := CmdLineLim-Length(Prg+Cmd)-7;
CmdLineOK := False;
SS1 := Lst; {¤«ï ¯¥à¥áâà 客ª¨}
repeat
if Length(Lst) >= ListLineLim then
begin
for I := ListLineLim downto 1 do
if Lst[I] = #$14 then