-
Notifications
You must be signed in to change notification settings - Fork 10
/
Copy pathtree.pas
2134 lines (2022 loc) · 53.3 KB
/
tree.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).
//
//////////////////////////////////////////////////////////////////////////}
{$I STDEFINE.INC}
unit Tree;
interface
uses
Objects, Drivers, Defines, Streams,
Dialogs, Views, FilesCol
;
type
PTreeWindow = ^TTreeWindow;
TTreeWindow = object( {TStd}TWindow)
constructor Init(var Bounds: TRect);
function GetPalette: PPalette; virtual;
procedure HandleEvent(var Event: TEvent); virtual;
constructor Load(var S: TStream);
procedure Store(var S: TStream);
end;
PTreeReader = ^TTreeReader;
TTreeReader = object(TView)
procedure HandleEvent(var Event: TEvent); virtual;
end;
PTreeDialog = ^TTreeDialog;
TTreeDialog = object(TDialog)
Tree: PView;
isValid: Boolean;
constructor Init(R: TRect; const ATitle: String; ADrive: Byte);
{procedure HandleEvent(var Event: TEvent); virtual;}
function GetPalette: PPalette; virtual;
function Valid(Command: Word): Boolean; virtual;
end;
PDirRec = ^TDirRec;
TDirRec = record
Level: Byte;
Cluster: Word;
Size: TSize;
Attr: Byte;
NumFiles: LongInt;
Date: LongInt;
Number: Integer;
DirName: TFlName;
Dummy: array[1..SizeOf(ShortString)-SizeOf(TShortName)] of Char;
{á¬. ª®¬¬¥â ਩ ª TFileRec}
end;
PTreeView = ^TTreeView;
TTreeView = object(TView)
ScrollBar: PScrollBar;
CurPtr: PDirRec;
isValid {, QuickSearch}: Boolean;
Drive, SearchPos: Byte;
CurPath, LastPath: String; {DataCompBoy}
DC, Dirs: PCollection;
Delta: TPoint;
CurNum: Integer;
Parital, DrawDisabled,
LocateEnabled, MouseTracking, WasChanged: Boolean;
InfoView: PView;
constructor Init(R: TRect; ADrive: Integer; ParitalView: Boolean;
ScrBar: PScrollBar);
constructor Load(var S: TStream);
procedure Store(var S: TStream);
function Valid(Command: Word): Boolean; virtual;
function Expanded(P: PDirRec; i: Integer): Boolean;
procedure SetState(AState: Word; Enable: Boolean); virtual;
procedure ReadTree(CountLen: Boolean);
procedure Reread(CountLen: Boolean);
procedure HandleEvent(var Event: TEvent); virtual;
procedure HandleCommand(var Event: TEvent);
function GetDirName(N: Integer): String;
procedure SetData(var Rec); virtual;
procedure GetData(var Rec); virtual;
procedure CollapseBranch(N: Integer);
function DataSize: Word; virtual;
function FindDir(Dir: String): Integer; {DataCompBoy}
procedure ReadAfterLoad;
function GetPalette: PPalette; virtual;
procedure Draw; virtual;
destructor Done; virtual;
end;
PTreePanel = ^TTreePanel;
TTreePanel = object(TTreeView)
procedure HandleEvent(var Event: TEvent); virtual;
end;
PTreeInfoView = ^TTreeInfoView;
TTreeInfoView = object(TView)
Tree: PTreeView;
Down: String;
Loaded: Boolean;
constructor Init(R: TRect; ATree: PTreeView);
procedure Draw; virtual;
procedure HandleEvent(var Event: TEvent); virtual;
procedure MakeDown;
constructor Load(var S: TStream);
procedure Store(var S: TStream);
function GetPalette: PPalette; virtual;
destructor Done; virtual;
end;
PDTreeInfoView = ^TDTreeInfoView; { ¤¥à¥¢® ¢ ¤¨ «®£¥ }
TDTreeInfoView = object(TTreeInfoView)
function GetPalette: PPalette; virtual;
end;
PHTreeView = ^THTreeView;
{`2 ¯ ¥«ì ¤¥à¥¢ á ¯®¤¢ «®¬ `}
THTreeView = object(TTreePanel)
Info: PView;
constructor Init(R: TRect; ADrive: Integer; ParitalView: Boolean;
ScrBar: PScrollBar);
procedure ChangeBounds(var Bounds: TRect); virtual;
constructor Load(var S: TStream);
procedure Store(var S: TStream);
function GetPalette: PPalette; virtual;
procedure SetState(AState: Word; Enable: Boolean); virtual;
destructor Done; virtual;
end;
PDirCollection = ^TDirCollection;
TDirCollection = object(TCollection)
procedure FreeItem(P: Pointer); virtual;
function GetItem(var S: TStream): Pointer; virtual;
procedure PutItem(var S: TStream; Item: Pointer); virtual;
end;
function ChangeDir(ATitle: TTitleStr; Drv: Byte): String; {DataCompBoy}
procedure CheckMkDir(const Path: String);
{` MkDir and check result AK155 `}
procedure MakeDirectory;
{` ‘®§¤ âì ª â «®£(¨) ¢ ¤¨ «®£¥. ” ªâ¨ç¥áª¨, íâ® TDrive.MakeDir.
‚ ¢¢¥¤ñ®© áâப¥ ¬®¦â ¡ëâì ¥áª®«ìª® ª â «®£®¢, à §¤¥«ñëå
â®çª ¬¨ á § ¯ï⮩.
ˆ¬ï ¯¥à¢®£® á®§¤ ®£® ª â «®£ á ¯®«ë¬ ¯ãâñ¬ ¡¥§ á«íè ¯®¬¥é ¥âáï ¢
¯¥à¥¬¥ãî CreatedDir. …᫨ ª â «®£ ¥ á®§¤ «áï - CreatedDir=''.
¥à¥¬¥ ï CreatedDir ¨á¯®«ì§ã¥âáï ¢ ARVIDAVT.PAS, ¨ ¯®¤®§à¥¢ î, çâ®
¢ ª ª®¬-â® ¤à㣮¬ á¬ëá«¥. `}
procedure FreeTree(C: Char);
function GetDirLen(Dir: String): TSize; {DataCompBoy}
function CreateDirInheritance(var S: String; Confirm: Boolean): Byte;
{` ‘®§¤ âì ª â «®£ «î¡®© ¢«®¦¥®áâ¨. S à §¢®à 稢 ¥âáï ¯à¨
¯®¬®é¨ lFExpand ¨ ¤®¯®«ï¥âáï '\' ¢ ª®æ¥, ¨ íâ® § 票¥
®áâ ñâáï ¯®á«¥ ¢ë§®¢ .
¥§ã«ìâ â - ¤«¨ ¯ã⨠(â® ¥áâì ¯®¤áâப¨ S) ª â «®£ , ¢
ª®â®à®¬ 室¨âáï á ¬ë© ¢¥è¨© á®§¤ ë© ª â «®£ (¡¥§ á«íè ).
¯à¨¬¥à, ¥á«¨ s='C:\TEMP\AAA\BBB' ¨ ª â «®£ C:\TEMP áãé¥á⢮¢ «,
C:\TEMP\AAA ¡ë« á®§¤ , ⮠१ã«ìâ â - 7. ‘¬ëá« í⮣® ¢ ⮬,
çâ® ¥á«¨ C:\TEMP ®âªàëâ ª ª®©-â® ¯ ¥«¨, â® íâã ¯ ¥«ì ¤®
¯¥à¥ç¨â âì, çâ®¡ë ¥© ¯®ï¢¨«áï AAA.
…᫨ ª â «®£¨ ¥ á®§¤ ¢ «¨áì - १ã«ìâ â 0. `}
const
CreatedDir: String = '';
{` ¥§ã«ìâ â MakeDirectory `}
TreeError: Boolean = False;
CHTreeView = #15#16#17#18#19#20#21;
CTreeInfoView = #22;
CDTreeInfoView = #30;
CTreeView = #35#36#37#38#39#40#41;
CTreeDialog = CDialog+#104#105#106#107#108#109#110;
var
DrvTrees: array['A'..'Z'] of record
C: PCollection;
len: Boolean;
end;
implementation
uses
Lfnvp, Files, Memory, Startup, Dos, DnIni, DNHelp,
Advance, Advance1, Advance2, Advance3,
FlPanelX, DNApp, Messages, Commands, Drives, Eraser, Menus,
xTime, FileCopy
;
const
trExpanded = $02;
trHasBranch = $04;
cmRevert = 200;
cmDirChanged = 201;
function ESC_Pressed: Boolean;
var
E: TEvent;
begin
Application^.Idle;
GetKeyEvent(E);
ESC_Pressed := (E.What = evKeyDown) and (E.KeyCode = kbESC)
end;
{DataCompBoy
function NotStr(S: String): String;
var I: Integer;
begin
for I := 1 to Length(S) do S[I] := Char(not Byte(S[I]) xor I);
NotStr := S;
end;
}
procedure ReadTree(C: Char; CountLen: Boolean);
label Rep, DRep;
var
P: PDirRec;
DCEntry: Integer;
Idx: Integer;
D, S: String; {DataCompBoy}
Lv, I: Integer;
DSize: Word;
Dr: array[1..255] of Integer;
DC: PDirCollection;
Tmr: TEventTimer;
procedure ChkESC;
begin
if Abort then
Exit;
if TimerExpired(Tmr) then
begin
NewTimer(Tmr, 150);
Abort := ESC_Pressed;
end;
end;
{-DataCompBoy-}
procedure DosReadDirectory(PD: PDirRec);
var
I: Integer;
Lv: Integer;
S: String;
SR: lSearchRec;
P: PDirRec;
begin
I := DC^.IndexOf(PD);
Lv := PD^.Level;
PD^.Size := 0;
P := PD;
S := MakeNormName(PD^.DirName[uLfn], '');
repeat
while (I > 0) and (P^.Level <= PDirRec(DC^.At(I))^.Level) do
Dec(I);
if DC^.IndexOf(PD) <> I then
begin
P := DC^.At(I);
S := MakeNormName(P^.DirName[uLfn], S);
end;
until I = 0;
ClrIO;
if Abort then
Exit;
I := DC^.IndexOf(PD);
lFindFirst(S+x_x, AnyFileDir, SR); {JO}
while (DosError = 0) and not Abort do
begin
if not IsDummyDir(SR.SR.Name) then
begin
if SR.SR.Attr and Directory <> 0 then
begin
New(P);
CopyShortString(SR.SR.Name, P^.DirName[uLfn]);
P^.Cluster := 0;
P^.NumFiles := 0;
P^.Size := -1;
P^.Level := PD^.Level+1;
Inc(I);
DC^.AtInsert(I, P);
end
else
begin
PD^.Size := PD^.Size+SR.FullSize;
Inc(PD^.NumFiles);
end;
end;
lFindNext(SR);
end;
lFindClose(SR);
DosError := 0;
ClrIO;
end { DosReadDirectory };
{-DataCompBoy-}
var
PD: PDirRec;
RemoteDrive: Boolean;
Info: PView;
{-DataCompBoy-}
begin { ReadTree }
{Cat:warn ¤® ¤®¡ ¢¨âì ¢ë¢®¤ ¤¥à¥¢ ¤«ï á¥â¥¢ëå ¯ã⥩}
NewTimer(Tmr, 1);
C := UpCase(C);
if not (C in ['A'..'Z']) then
Exit;
if DrvTrees[C].C <> nil then
Dispose(DrvTrees[C].C, Done);
DrvTrees[C].C := nil;
TreeError := True;
if LowMemory then
Exit;
New(DC, Init(10, 10));
New(P);
FillChar(P^, SizeOf(P^), 0);
P^.DirName[uLfn] := C+':\';
P^.Cluster := 0;
P^.Level := 0;
P^.Size := -1;
P^.Attr := 0;
DC^.Insert(P);
Abort := False;
RemoteDrive := False;
begin
Info := WriteMsg(GetString(dlScanningDirs));
DrvTrees[C].C := DC;
DrvTrees[C].len := True;
DRep:
ChkESC;
if not Abort then
for DCEntry := 1 to DC^.Count do
begin
UpdateWriteView(Info);
P := DC^.At(DCEntry-1);
if P^.Size < 0 then
if (not Abort) and (P^.Level < 40) then
begin
DosReadDirectory(P);
goto DRep
end
else
P^.Size := 0;
end;
Dispose(Info, Done);
if Abort then
begin
Dispose(DC, Done);
DrvTrees[C].C := nil;
TreeError := True;
Exit;
end;
end
;
for I := 1 to DC^.Count do
begin
P := DC^.At(I-1);
Lv := I;
P^.Number := I-1;
P^.Attr := 0;
while (Lv < DC^.Count) and (PDirRec(DC^.At(Lv))^.Level > P^.Level)
do
begin
PD := DC^.At(Lv);
Inc(P^.NumFiles, PD^.NumFiles);
P^.Size := P^.Size+PD^.Size;
Inc(Lv);
end;
if (Lv < DC^.Count) and (PDirRec(DC^.At(Lv))^.Level = P^.Level)
then
P^.Attr := 1;
if (I < DC^.Count) and (PDirRec(DC^.At(I))^.Level > P^.Level) then
P^.Attr := P^.Attr or trHasBranch;
end;
TreeError := False;
end { ReadTree };
{-DataCompBoy-}
function GetDirCollection(C: Char; CountLen: Boolean): PCollection;
begin
GetDirCollection := nil;
C := UpCase(C);
if not (C in ['A'..'Z']) then
Exit;
if (DrvTrees[C].C = nil) or (not DrvTrees[C].len and CountLen)
then
ReadTree(C, CountLen);
GetDirCollection := DrvTrees[C].C;
end;
{-DataCompBoy-}
function FindDir(DC: PCollection; const Dir: String): Integer;
var
I, Lv: Integer;
S, D: String;
P: PDirRec;
begin
FindDir := -1;
if DC = nil then
Exit;
D := Dir;
Lv := 1;
I := 1;
Delete(D, 1, 3);
if D = '' then
begin
FindDir := 0;
Exit
end;
repeat
S := '';
while (D[1] <> '/') and (D <> '') do // slash change by unxed
begin
S := S+D[1];
Delete(D, 1, 1); {DelFC(D)}
end;
Delete(D, 1, 1); {DelFC(D);}
UpStr(S);
if (S <> '') and (I < DC^.Count) then
begin
repeat
if I < DC^.Count then
P := DC^.At(I);
while (I < DC^.Count) and (P^.Level > Lv) do
begin
Inc(I);
if I < DC^.Count then
P := DC^.At(I);
end;
while (I < DC^.Count) and (P^.Level = Lv)
and (UpStrg(P^.DirName[uLfn]) <> S)
do
begin
Inc(I);
if I < DC^.Count then
P := DC^.At(I);
end
until (I >= DC^.Count) or
( (UpStrg(P^.DirName[uLfn]) = S)
and (P^.Level = Lv)) or (P^.Level < Lv)
end
else if S = '' then
I := 1;
if D <> '' then
Inc(I);
Inc(Lv);
until (D = '') or (I >= DC^.Count) or (Lv > 128) { :) };
if (I >= DC^.Count) or (UpStrg(P^.DirName[uLfn]) <> S)
then
FindDir := -1
else
FindDir := I
end { FindDir };
{-DataCompBoy-}
function GetDirLen(Dir: String): TSize; {DataCompBoy}
var
DC: PCollection;
I: Integer;
R: Boolean;
procedure MakeReread(P: PView);
var
Event: TEvent;
begin
Event.What := evCommand;
Event.Command := cmRereadTree;
Event.InfoPtr := @Dir;
if P <> nil then
P^.HandleEvent(Event);
end;
begin
GetDirLen := 0;
Dir[1] := UpCase(Dir[1]);
R := (DrvTrees[Dir[1]].C <> nil) and not (DrvTrees[Dir[1]].len);
DC := GetDirCollection(Dir[1], True);
if DC = nil then
Exit;
if R then
Desktop^.ForEach(@MakeReread);
I := FindDir(DC, Dir);
if I < 0 then
Exit;
GetDirLen := PDirRec(DC^.At(I))^.Size;
end { GetDirLen };
procedure FreeTree(C: Char);
begin
C := UpCase(C);
if not (C in ['A'..'Z']) then
Exit;
Dispose(DrvTrees[C].C, Done);
DrvTrees[C].C := nil;
end;
procedure TTreeReader.HandleEvent;
var
C: Char;
S: String;
begin
inherited HandleEvent(Event);
if (Event.What = evCommand)
then
case Event.Command of
cmRereadTree:
begin
S := UpStrg(PString(Event.InfoPtr)^);
C := S[1];
if (C in ['A'..'Z']) and (DrvTrees[C].C <> nil) then
begin
Dispose(DrvTrees[C].C, Done);
DrvTrees[C].C := nil;
GlobalMessage(evCommand, cmFindTree, @C);
if C = #0 then
begin
C := S[1];
ReadTree(C, DrvTrees[C].len)
end
else
DrvTrees[C].len := False;
end;
end;
end {case}; { case }
end { TTreeReader.HandleEvent };
procedure CheckMkDir(const Path: String);
var
rc: LongInt;
label Start;
begin
Start:
lMkDir(Path);
rc := IOResult;
{AK155 29-05-2002
ਠᮧ¤ ¨¨ áãé¥áâ¢ãî饣® ª â «®£ (çâ® ¥ ¥áâì ®è¨¡ª )
¯®¤ OS/2 rc=5, ¯®¤ WinNT - rc=183.
ਠᮧ¤ ¨¨ ª â «®£ CD (çâ® ¥áâì ®è¨¡ª )
¯®¤ OS/2 rc=19, ¯®¤ WinNT - rc=5.
Š ª ®® ¡ã¤¥â ¯®¤ Win9x ¨«¨ DPMI - ⮦¥ ¥é¥ ¢®¯à®á.
®í⮬㠯à®é¥ ¨ ªªãà ⥥ ¯à®¢¥à¨âì ä ªâ¨ç¥áª®¥ «¨ç¨¥, ¥
«¨§¨à®¢ âì rc }
if not PathExist(Path) then
(* if (rc <> 0) and (rc <> 5 {ª â «®£ 㦥 áãé¥áâ¢ã¥â}) {$IFDEF Win32} and (rc <> 183) {$ENDIF} then*)
begin
if SysErrorFunc(rc, Byte(Path[1])-Byte('A')) = 1 then
goto Start;
rc := MessageBox(GetString(dlFCNoCreateDir)+Path, nil,
mfError+mfOKButton);
Abort := True;
end;
end { CheckMkDir };
{-DataCompBoy-}
procedure MakeDirectory;
var
S, S1: String;
Dr: String;
Nm: String;
XT: String;
B: Byte;
I: Integer;
j: Boolean;
W: Word;
begin
CreatedDir := '';
if LowMemory then
Exit;
S := '';
W := ExecResource(dlgMkDir, S);
if W = cmYes then
UpStr(S)
else if W = cmNo then
LowStr(S)
else if W <> cmOK then
Exit;
DelRight(S);
{$IFDEF DPMI32}
DelLeft(S);
{$ENDIF}
if S = '' then
Exit;
{$IFDEF RecodeWhenDraw}
S := OemToCharStr(S);
{$ENDIF}
CreatedDir := '';
while S <> '' do
begin
j := False;
I := 0;
while (I < Length(S)) do
begin
Inc(I);
if not j and (S[I] = ';') then
Break;
if S[I] = '"' then
j := not j;
end;
if I = Length(S) then
Inc(I);
if I = 0 then
I := Length(S)+1;
S1 := DelSquashes(Copy(S, 1, I-1));
Delete(S, 1, I);
if S1 = '' then
Continue;
B := CreateDirInheritance(S1, False);
if Abort or (IOResult <> 0) then
Exit;
SetLength(S1, Length(S1)-1); // 㤠«¨âì á«íè
if CreatedDir = '' then
CreatedDir := S1;
{ ®¯à¥¤¥«¥¨¥ ª â «®£ ¤«ï ¯¥à¥ç¨âë¢ ¨ï }
if B > 0 then
SetLength(S1, B)
else
begin
lFSplit(S1, S1, Nm, XT);
SetLength(S1, Length(S1)-1); // 㤠«¨âì á«íè
end;
RereadDirectory(S1);
GlobalMessage(evCommand, cmRereadTree, @Dr);
GlobalMessage(evCommand, cmRereadInfo, nil);
end;
end { MakeDirectory };
{-DataCompBoy-}
function ChangeDir;
var
D: PTreeDialog;
S: String;
R: TRect;
begin
R.Assign(1, 1, 50, 18);
Abort := False;
ChangeDir := '';
New(D, Init(R, ATitle, Drv));
D^.Options := D^.Options or ofCentered;
S := '';
D := PTreeDialog(Application^.ValidView(D));
if D <> nil then
if Desktop^.ExecView(D) = cmOK then
D^.GetData(S);
ChangeDir := S;
end;
destructor TTreeInfoView.Done;
begin
PHTreeView(Tree).Info := nil;
inherited Done;
end;
constructor TTreeInfoView.Init;
begin
inherited Init(R);
Tree := ATree;
Options := Options or ofPostProcess;
EventMask := evBroadcast;
GrowMode := gfGrowHiX+gfGrowHiY+gfGrowLoY;
MakeDown;
Loaded := False;
end;
procedure TTreeInfoView.HandleEvent;
begin
inherited HandleEvent(Event);
if (Event.What = evBroadcast) and (Event.Command = cmDirChanged) then
begin
MakeDown;
DrawView
end;
end;
constructor TTreeInfoView.Load;
begin
inherited Load(S);
GetPeerViewPtr(S, Tree);
Loaded := True;
end;
procedure TTreeInfoView.Store;
begin
inherited Store(S);
PutPeerViewPtr(S, Tree);
end;
function TTreeInfoView.GetPalette;
const
S: String[Length(CTreeInfoView)] = CTreeInfoView;
begin
GetPalette := @S;
end;
function TDTreeInfoView.GetPalette;
const
S: String[Length(CDTreeInfoView)] = CDTreeInfoView;
begin
GetPalette := @S;
end;
procedure TTreeInfoView.Draw;
var
B: TDrawBuffer;
C: Byte;
begin
C := GetColor(1);
if Loaded then
MakeDown;
Loaded := False;
MoveChar(B, ' ', C, Size.X);
MoveStr(B[1], Cut(Tree^.CurPath, Size.X), C);
WriteLine(0, 0, Size.X, 1, B);
MoveChar(B, ' ', C, Size.X);
MoveStr(B[1], Down, C);
WriteLine(0, 1, Size.X, 1, B);
end;
procedure TTreeInfoView.MakeDown;
{var L: Array [1..5] of Longint;}
var
L1: LongInt;
L2: TSize;
begin
{L[1] := Tree^.CurPtr^.NumFiles;}
{L[2] := Tree^.CurPtr^.Size;}
if (Tree <> nil) and (Tree^.CurPtr <> nil) then
begin
L1 := Tree^.CurPtr^.NumFiles;
L2 := Tree^.CurPtr^.Size;
if L1 <> 1 then
Down := ItoS(L1)+GetString(dlTreeFilesWith)
else
Down := GetString(dlTree1FileWith);
if L2 <> 1 then
Down := Down+FStr(L2)+' '+GetString(dlDIBytes)
else
Down := Down+' 1'+GetString(dlDIByte);
end;
end;
constructor TTreeDialog.Init;
var
R1, R2: TRect;
P: PView;
begin
inherited Init(R, ATitle);
HelpCtx := hcTreeDialog;
isValid := True;
if R.B.X-R.A.X < 24 then
R.Grow(24+R.A.X-R.B.X, 0);
if R.B.Y-R.A.Y < 8 then
R.B.Y := R.A.Y+8;
GetExtent(R);
R.Grow(-1, -1);
R1 := R;
Dec(R1.B.X, 14);
P := StandardScrollBar(sbVertical+sbHandleKeyboard);
Dec(P^.Origin.X, 14);
Dec(R1.B.Y);
Tree := New(PTreeView, Init(R1, ADrive, False, PScrollBar(P)));
if Tree^.Valid(0) then
Insert(Tree)
else
begin
Dispose(Tree, Done);
Tree := nil;
isValid := False;
Exit;
end;
R1.A.Y := R1.B.Y;
Inc(R1.B.Y);
P := New(PDTreeInfoView, Init(R1, PTreeView(Tree)));
Insert(P);
R1.Assign(R.B.X-13, R.A.Y+1, R.B.X-1, R.A.Y+3);
P := New(PButton, Init(R1, GetString(dlOKButton), cmOK, bfDefault));
Insert(P);
R1.Assign(R.B.X-13, R.A.Y+4, R.B.X-1, R.A.Y+6);
P := New(PButton, Init(R1, GetString(dlDriveButton), cmChangeDrive,
bfBroadcast));
{P^.Options := P^.Options and not ofSelectable;}
Insert(P);
R1.Assign(R.B.X-13, R.A.Y+7, R.B.X-1, R.A.Y+9);
P := New(PButton, Init(R1, GetString(dlRereadButton), cmPanelReread,
bfBroadcast));
Insert(P);
R1.Assign(R.B.X-13, R.A.Y+10, R.B.X-1, R.A.Y+12);
P := New(PButton, Init(R1, GetString(dlMkDirButton), cmPanelMkDir,
bfBroadcast));
Insert(P);
R1.Assign(R.B.X-13, R.A.Y+13, R.B.X-1, R.A.Y+15);
P := New(PButton, Init(R1, GetString(dlCancelButton), cmCancel, 0));
Insert(P);
SelectNext(False);
Options := Options or ofTopSelect;
end { TTreeDialog.Init };
function TTreeDialog.GetPalette;
const
S: String[Length(CTreeDialog)] = CTreeDialog;
begin
GetPalette := @S;
end;
function TTreeDialog.Valid;
begin
Valid := isValid and inherited Valid(Command)
end;
(*procedure TTreeDialog.HandleEvent;
begin
{if Event.What = evCommand then Tree^.HandleEvent(Event);}
inherited HandleEvent(Event);
end;*)
constructor TTreeWindow.Init;
var
R: TRect;
P: PView;
S: PScrollBar;
begin
inherited Init(Bounds, GetString(dlTreeTitle), 0);
GetExtent(R);
R.Grow(-1, -1);
R.A.X := R.B.X;
Inc(R.B.X);
S := StandardScrollBar(sbVertical+sbHandleKeyboard);
GetExtent(R);
R.Grow(-1, -1);
Dec(R.B.Y, 2);
P := New(PTreePanel, Init(R, 0, True, S));
Insert(P);
GetExtent(R);
R.Grow(-1, -1);
R.A.Y := R.B.Y-2;
P := New(PTreeInfoView, Init(R, PTreeView(P)));
Insert(P);
end { TTreeWindow.Init };
constructor TTreeWindow.Load;
begin
inherited Load(S);
PTreeView(Current)^.ReadAfterLoad;
end;
procedure TTreeWindow.Store;
begin
inherited Store(S);
end;
function TTreeWindow.GetPalette;
const
S: String[Length(CTreeDialog)] = CTreeDialog;
begin
GetPalette := @S;
end;
procedure TTreeWindow.HandleEvent(var Event: TEvent);
begin
case Event.What of
evKeyDown:
if (Event.KeyCode = kbESC) then
begin
Message(Application, evCommand, cmClose, nil);
ClearEvent(Event);
end;
end {case};
inherited HandleEvent(Event);
end;
constructor TTreeView.Init;
var
I, Lv: Integer;
S, D: String;
P: PDirRec;
begin
inherited Init(R);
Abort := False;
if ParitalView then
HelpCtx := hcDirTree;
EventMask := $FFFF;
lGetDir(ADrive, CurPath); {DataCompBoy}
ScrollBar := ScrBar;
Drive := ADrive;
LastPath := CurPath;
Options := Options or ofSelectable {or ofTopSelect} or ofFirstClick;
Parital := ParitalView;
if Parital then
Options := Options or ofTopSelect;
GrowMode := gfGrowHiX+gfGrowHiY;
WasChanged := False;
Dirs := nil;
DC := nil;
MouseTracking := False;
LocateEnabled := True;
if not Abort then
ReadTree(False);
StopQuickSearch;
DrawDisabled := False;
isValid := not Abort and (ScrollBar <> nil);
end { TTreeView.Init };
destructor TTreeView.Done;
begin
if DC <> nil then
begin
DC^.DeleteAll;
Dispose(DC, Done);
DC := nil;
end;
inherited Done;
end;
function TTreeView.GetPalette;
const
S: String[Length(CTreeView)] = CTreeView;
begin
GetPalette := @S;
end;
constructor TTreeView.Load;
var
P: Pointer;
begin
inherited Load(S);
GetPeerViewPtr(S, ScrollBar);
S.Read(Parital, 1);
S.ReadStrV(LastPath);
{S.Read(LastPath[0], 1); S.Read(LastPath[1], Length(LastPath));}
CurPath := LastPath;
Drive := Byte(LastPath[1])-64;
StopQuickSearch;
DrawDisabled := False;
LocateEnabled := True;
Dirs := nil;
DC := nil;
isValid := True;
WasChanged := False;
MouseTracking := False;
end;
procedure TTreeView.ReadAfterLoad;
begin
Abort := False;
ReadTree(False);
isValid := not Abort and (ScrollBar <> nil);
end;
function THTreeView.GetPalette;
const
S: String[Length(CHTreeView)] = CHTreeView;
begin
GetPalette := @S;
end;
procedure TTreeView.Store;
begin
inherited Store(S);
PutPeerViewPtr(S, ScrollBar);