-
Notifications
You must be signed in to change notification settings - Fork 5
/
COMMAND.PAS
2004 lines (1944 loc) · 49.4 KB
/
COMMAND.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
{ @author: Sylvain Maltais ([email protected])
@created: 2021
@website(https://www.gladir.com/corail)
@abstract(Target: Turbo Pascal, Free Pascal)
}
Program COMMAND;
{$M 8192,0,0}
Uses Crt,DOS;
Const
CommandList:Array[0..36]of String[8]=(
'BREAK','CALL','CD','CHCP','CHDIR','CLS','COPY','CTTY','DEL','DELETE',
'DIR','ECHO','ERA','ERASE','EXIT','FOR','IF','LOADHIGH','MD','MKDIR',
'PATH','PAUSE','PROMPT','RD','REM','REN','RENAME','RMDIR','SET',
'SHIFT','TIME','TRUENAME','TYPE','VER','VERIFY','VOL','DATE'
);
Var
Language:(_French,_English,_Germany,_Italian,_Spain);
TmpLanguage:String;
Pipe,PipeToCommand:Boolean;
PipeFile:Text;
InCmd:Byte;
Option:(optNone,optCommand);
Echo:Boolean;
CommandFound,Terminated:Boolean;
CmdStr:String;
CurrCommand,ParamList,PipeCommand:String;
I,J:Byte;
Procedure RunCommand;Forward;
Function PadRight(S:String;Space:Byte):String;
Var
I:Byte;
Begin
If Length(S)<Space Then For I:=Length(S)+1 to Space do S:=S+' ';
PadRight:=S;
End;
Function PadZeroLeft(Value:Integer;Space:Byte):String;
Var
S:String;
Begin
Str(Value,S);
While Length(S)<Space do S:='0'+S;
PadZeroLeft:=S;
End;
Function TrimL(S:String):String;
Var
I:Byte;
Begin
For I:=1to Length(S)do Begin
If S[I]<>' 'Then Begin
TrimL:=Copy(S,I,255);
Exit;
End;
End;
TrimL:=S;
End;
Function TrimR(s:String):String;
Var
i:Integer;
Begin
i:=Length(s);
While (i>0)and(s[i]in[#9,' '])do Dec(i);
s[0]:=Chr(i);
TrimR:=S;
End;
Function Trim(s:String):String;Begin
Trim:=TrimL(TrimR(s));
End;
Function StrToUpper(S:String):String;
Var
I:Byte;
Begin
For I:=1 to Length(S)do Begin
If S[I] in['a'..'z']Then S[I]:=Chr(Ord(S[I])-32);
End;
StrToUpper:=S;
End;
Function GetCurrentDisk:Char;
Var
CurrentDir:String;
Begin
GetDir(0,CurrentDir);
GetCurrentDisk:=CurrentDir[1];
End;
Function FileExist(Name:String):Boolean;
Var
Rec:SearchRec;
Begin
FindFirst(Name,AnyFile,Rec);
FileExist:=DosError=0;
End;
Function Path2Drive(Path:String):Char;Begin
Path:=FExpand(Path);
Path2Drive:=Path[1];
End;
Function GetDiskLabel(Dsk:Byte):String;
Var
Info:SearchRec;
CurrentDir:String;
Begin
If Dsk=0Then GetDir(0,CurrentDir)
Else CurrentDir:=Char(Dsk+64);
FindFirst(CurrentDir[1]+':\*.*',VolumeID,Info);
While DosError=0do Begin
If(Info.Attr = VolumeID)Then Begin
GetDiskLabel:=Info.Name;
Exit;
End;
FindNext(Info);
End;
GetDiskLabel:=''
End;
Procedure SetEnv(EnvVar,Value:String);
Var
Link,
PrevLink,
EnvirP:Word;
Size,Scan,Where,Dif:Integer;
NewVar,OldVar,Test:String;
Function CheckSpace(Wanted:Integer):Boolean;Begin
If Wanted+Scan>Size Then InOutRes:=8;
CheckSpace := inoutres = 0;
End;
Begin
{$IFNDEF FPC}
If InOutRes>0 Then Exit;
For Scan:=1 TO Length(EnvVar)do EnvVar[Scan]:=UpCase(EnvVar[Scan]);
EnvVar:=EnvVar+'=';
NewVar:=EnvVar+Value+#0;
link:=PrefixSeg;
Repeat
PrevLink:=Link;
Link:=MemW[link:$16];
Until Link=prevlink;
EnvirP:=MemW[Link:$2C];
Size:=MemW[Envirp-1:$03]*16;
Scan:=0;
Where:=-1;
While mem[EnvirP:Scan]<>0 do Begin
Move(mem[EnvirP:Scan],Test[1],255);
Test[0]:=#255;
Test[0]:=Chr(pos(#0,Test));
If Pos(EnvVar,Test)=1 Then Begin
Where:=Scan;
OldVar:=Test;
End;
Scan:=Scan+Length(Test);
End;
If Where=-1 Then Begin
Where:=Scan;
NewVar:=NewVar+#0#0#0;
If Not CheckSpace(Length(NewVar)) Then Exit;
End
Else
Begin
Dif:=Length(NewVar)-Length(OldVar);
If Dif>0 Then Begin
If Not CheckSpace(Dif)Then Exit;
Move(mem[EnvirP:Where], mem[EnvirP:Where+Dif],Scan-Where+3);
End
Else
If Dif<0 Then Move(mem[EnvirP:Where-Dif],Mem[EnvirP:Where],Size-Where+Dif);
End;
Move(NewVar[1],Mem[EnvirP:Where],Length(NewVar));
{$ENDIF}
End;
Function CopyFile(Source,Target:String;ShowProgression:Boolean):Boolean;
Var
SourceFile,TargetFile:File;
RecordsRead:Integer;
Buffer:Array[1..1000]of Byte;
Begin
CopyFile:=False;
Assign(SourceFile,Source);
{$I-}Reset(SourceFile,1);{$I+}
If IOResult<>0Then Begin
WriteLn('Fichier source introuvable ',Source);
Exit;
End;
Assign(TargetFile,Target);
{$I-}Rewrite(TargetFile,1);
If(ShowProgression)Then WriteLn('. = 1000 octets de copies');
BlockRead(SourceFile,Buffer,SizeOf(Buffer),RecordsRead);
While RecordsRead>0 do Begin
If(ShowProgression)Then Write('.');
BlockWrite(TargetFile,Buffer,RecordsRead);
BlockRead(SourceFile,Buffer,SizeOf(Buffer),RecordsRead);
End;
If(ShowProgression)Then WriteLn;
Close(SourceFile);
Close(TargetFile);
{$I+}
CopyFile:=True;
End;
Function GetErrorMessage(Code:Word):String;Begin
Case Code of
0:GetErrorMessage:='';
2:GetErrorMessage:='Fichier introuvable';
3:GetErrorMessage:='Chemin introuvable';
4:GetErrorMessage:='Trop de fichiers ouvert';
5:GetErrorMessage:='Acces refuse';
6:GetErrorMessage:='Handle de fichier invalide';
12:GetErrorMessage:='Mode d''acces sur disque invalide';
15:GetErrorMessage:='Num‚ro de disque invalide';
16:GetErrorMessage:='Impossible de supprimer le r‚pertoire';
17:GetErrorMessage:='Impossible de renommer sur plusieurs volumes';
100:GetErrorMessage:='Erreur de lecture … partir du disque';
101:GetErrorMessage:='Erreur d''ecriture sur le disque';
102:GetErrorMessage:='Fichier non attribue';
103:GetErrorMessage:='Le fichier n''est pas ouvert';
104:GetErrorMessage:='Le fichier n''est pas ouvert … l''entree';
105:GetErrorMessage:='Le fichier n''est pas ouvert … la sortie';
106:GetErrorMessage:='Numero invalide';
150:GetErrorMessage:='Disque protege en ecriture';
151:GetErrorMessage:='Peripherique est inconnu';
152:GetErrorMessage:='Disque pas pret';
153:GetErrorMessage:='Commande inconnue';
154:GetErrorMessage:='Echec de verification CRC';
155:GetErrorMessage:='Disque invalide';
156:GetErrorMessage:='Erreur de recherche sur disque';
157:GetErrorMessage:='Type de media invalide';
158:GetErrorMessage:='Secteur introuvable';
159:GetErrorMessage:='L''imprimante n''a plus de papier';
160:GetErrorMessage:='Erreur d''ecriture sur le peripherique';
161:GetErrorMessage:='Erreur de lecture sur le peripherique';
162:GetErrorMessage:='Defaillance materielle';
Else GetErrorMessage:='Erreur inconnue';
End;
End;
Procedure ExtractCommand;
Var
I,J:Byte;
Begin
For I:=1 to Length(CmdStr)do Begin
If Not(CmdStr[I]in['A'..'Z','a'..'z','_','-','0'..'9'])Then Begin
CurrCommand:=StrToUpper(Copy(CmdStr,1,I-1));
ParamList:=TrimL(Copy(CmdStr,I,255));
For J:=1 to Length(ParamList)do Begin
Case ParamList[J]of
'|':Begin
If Not(Pipe)Then Begin
{$I-}Assign(PipeFile,'COMMAND.TMP');
Rewrite(PipeFile);{$I-}
If IoResult<>0 Then Begin
WriteLn('Tuyau invalide !');
End;
Pipe:=True;
End;
PipeToCommand:=True;
PipeCommand:=TrimL(Copy(ParamList,J+1,255));
If J=1 Then ParamList:=''
Else ParamList:=Copy(ParamList,1,J-1);
End;
'>':Begin
If Not(Pipe)Then Begin
{$I-}Assign(PipeFile,TrimL(Copy(ParamList,J+1,255)));
Rewrite(PipeFile);{$I-}
If IoResult<>0 Then Begin
WriteLn('Tuyau invalide !');
End
Else
Pipe:=True;
End;
If J=1 Then ParamList:=''
Else ParamList:=Copy(ParamList,1,J-1);
End;
End;
End;
Exit;
End;
End;
CurrCommand:=StrToUpper(CmdStr);
ParamList:='';
End;
Function ExtractParam(Index:Byte):String;
Var
Count:Word;
LocalIndex:Word;
l:Byte;
Temp:String;
Begin
Temp:='';Count:=1;LocalIndex:=1;l:=0;
While Count<=Length(ParamList)do Begin
If Not(ParamList[Count] in [' ',#9])then Begin
If LocalIndex=Index Then Begin
While (Count<=Length(ParamList)) and (Not(ParamList[count] in[' ',#9])) and (l < 256) do Begin
Temp:=Temp+ParamList[count];
Inc(l);
Inc(Count);
end;
Temp[0]:=Char(l);
ExtractParam:=Temp;
Exit;
End;
While (Count<=Length(ParamList)) and (Not(ParamList[count] in [' ',#9])) do Inc(Count);
Inc(LocalIndex);
End;
If Count>=Length(ParamList)Then Break;
Inc(Count);
End;
ExtractParam:=Temp;
End;
Procedure HomeMessage;Begin
WriteLn;
WriteLn('MSDOS-0 COMMAND.COM');
WriteLn('gladir.com 2021. Tous droits reserves.');
WriteLn;
End;
Procedure ShowPrompt;
Const Week:Array[0..6]of String[3]=('Dim','Lun','Mar','Mer','Jeu','Ven','Sam');
Mon:Array[1..12]of String[3]=('Jan','Fev','Mar','Avr','Mai','Jui',
'Jul','Aou','Sep','Oct','Nov','Dec');
Var
SP,CurrentDir:String;
I:Byte;
Year,Month,Day,DayOfWeek,Hour,Min,Sec,Sec100:Word;
Begin
If Not(Echo)Then Exit;
GetDir(0,CurrentDir);
SP:=GetEnv('PROMPT');
If SP=''Then SP:='$P$G';
I:=1;
While I<=Length(SP)do Begin
If SP[I]='$'Then Begin
Inc(I);
Case SP[I] of
'D': Begin
GetDate(Year,Month,Day,DayOfWeek);
Write(Week[DayOfWeek],' ',Mon[Month],Day,',',Year);
End;
'T': Begin
GetTime(Hour,Min,Sec,Sec100);
Write(Hour,':',Min,':',Sec);
End;
'B' : Write('|');
'e','E' : Write(#27);
'g','G' : Write('>');
'N' : Write(GetCurrentDisk);
'p','P' : Begin
GetDir(0,CurrentDir);
Write(CurrentDir);
End;
'-','S' : Write(' ');
'V' : Write(Lo(DosVersion),'.',Hi(DosVersion));
'_','Z' : Write(#13#10);
'z' : Write('?');
End;
End
Else
Write(SP[I]);
Inc(I);
End;
End;
Procedure InvalidParam(P:Byte);Begin
WriteLn('Le parametre suivant est invalide : ',ExtractParam(P));
End;
Procedure BreakCommand;
Var
FirstParam:String;
X:Boolean;
Begin
FirstParam:=ExtractParam(1);
If FirstParam='/?'Then Begin
Case Language of
_Germany:Begin
WriteLn('Schaltet (zus„tzliche) šberwachung fr STRG+C ein (ON) oder aus (OFF).');
WriteLn;
WriteLn('BREAK [/?] [ON|OFF]');
End;
_English:Begin
WriteLn('Purpose: Display, enable, or disable Ctrl-C and Ctrl-Break checking.');
WriteLn;
WriteLn('Format: BREAK [/?] [ON|OFF]');
End;
Else Begin
WriteLn('BREAK Cette commande permet de fixer ou de demander l''‚tat du Ctrl+Break.');
WriteLn;
WriteLn('Syntaxe:');
WriteLn;
WriteLn('BREAK [/?] [ON|OFF]');
WriteLn;
WriteLn(' /? Ce paramŠtre permet d''afficher l''aide sur cette commande');
WriteLn(' OFF Ce paramŠtre permet de d‚sactiver le Ctrl+C ou Ctrl+Break.');
WriteLn(' ON Ce paramŠtre permet d''activer le Ctrl+C ou Ctrl+Break.');
End;
End;
End
Else
If StrToUpper(ParamList)='OFF'Then SetCBreak(False) Else
If StrToUpper(ParamList)='ON'Then SetCBreak(True)
Else
Begin
GetCBreak(X);
If(Pipe)Then Begin
Write(PipeFile,'BREAK = ');
If(X)Then WriteLn(PipeFile,'on')
Else WriteLn(PipeFile,'off');
End
Else
Begin
Write('BREAK = ');
If(X)Then WriteLn('on')
Else WriteLn('off');
End;
End;
End;
Procedure CallCommand;Begin
WriteLn('Cette commande n''est pas mise en oeuvre');
End;
Procedure ChDirCommand;
Var
Drive:Char;
Error:Word;
FirstParam,Dir,CurrPath:String;
Begin
FirstParam:=ExtractParam(1);
If FirstParam='/?'Then Begin
Case Language of
_Germany:Begin
WriteLn('Wechselt das aktuelle Verzeichnis oder zeigt dessen Namen an.');
WriteLn;
WriteLn('CD [path | -]');
WriteLn('CHDIR [path | -]');
End;
_English:Begin
WriteLn('Purpose: Display or change the current directory.');
WriteLn;
WriteLn('Format: CD [path | -]');
WriteLn(' ':14,'or');
WriteLn(' ':10,'CHDIR [path | -]');
End;
Else Begin
WriteLn('CHDIR Cette commande permet de fixer ou de demander le r‚pertoire courant.');
WriteLn;
WriteLn('Syntaxe:');
WriteLn;
WriteLn('CD [/?] chemin');
WriteLn('CHDIR [/?] chemin');
WriteLn;
WriteLn(' /? Ce paramŠtre permet d''afficher l''aide sur cette commande');
WriteLn(' chemin Ce paramŠtre permet d''indiquer le chemin du rep‚rtoire.');
End;
End;
End
Else
If Length(FirstParam)>0Then Begin
GetDir(0,CurrPath);
Drive:=GetCurrentDisk;
{$I-} ChDir(FirstParam);{$I+}
Error:=IoResult;
If Error<>0Then WriteLn(GetErrorMessage(Error));
If Drive<>GetCurrentDisk Then ChDir(CurrPath);
End
Else
Begin
GetDir(0,Dir);
WriteLn(Dir);
End;
End;
Procedure CHCPCommand;
Var
Err:Word;
Regs:Registers;
FirstParam:String;
Begin
FirstParam:=ExtractParam(1);
If FirstParam='/?'Then Begin
Case Language of
_Germany:Begin
WriteLn('Wechselt die aktuelle Codeseite oder zeigt deren Nummer an.');
WriteLn;
WriteLn('CHCP [/?] [nnn]');
WriteLn;
WriteLn('nnn Die Nummer einer Codeseite.');
End;
_English:Begin
WriteLn('Displays or sets the active code page number.');
WriteLn;
WriteLn('CHCP [/?] [nnn]');
WriteLn;
WriteLn('nnn Specify a code page number.');
End;
Else Begin
WriteLn('CHCP Cette commande permet de fixer ou de demander la page de codes.');
WriteLn;
WriteLn('Syntaxe:');
WriteLn;
WriteLn('CHCP [/?] [code]');
WriteLn;
WriteLn(' /? Ce parametre permet d''afficher l''aide sur cette commande');
WriteLn(' code Ce parametre permet d''indiquer la page de code');
End;
End;
End
Else
If FirstParam<>''Then Begin
Regs.AX:=$6602;
Val(FirstParam,Regs.BX,Err);
If Err=0Then Begin
Intr($21,Regs);
If(Regs.Flags and FCarry=FCarry)Then Begin
WriteLn('Impossible de changer le code de page actif');
End;
End
Else
WriteLn('Code de page invalide.');
End
Else
Begin
Regs.AX:=$6601;
Intr($21,Regs);
If(Regs.Flags and FCarry=FCarry)Then Begin
WriteLn('Page de code active inconnnu');
End
Else
WriteLn('Page de code active : ',Regs.BX);
End;
End;
Procedure CLSCommand;
Var
FirstParam:String;
Begin
FirstParam:=ExtractParam(1);
If FirstParam='/?'Then Begin
Case Language of
_Germany:Begin
WriteLn('L”scht den Bildschirminhalt.');
WriteLn;
WriteLn('CLS');
End;
_English:Begin
WriteLn('Purpose: Clear the video display and move the cursor to the upper left');
WriteLn;
WriteLn('Format: CLS [/?]');
End;
Else Begin
WriteLn('CLS Cette commande permet d''effacer l''‚cran.');
WriteLn;
WriteLn('Syntaxe:');
WriteLn;
WriteLn('CLS [/?]');
WriteLn;
WriteLn(' /? Ce paramŠtre permet d''afficher l''aide sur cette commande');
End;
End;
End
Else
Begin
ClrScr;
End;
End;
Procedure CopyCommand;
Var
P:Byte;
ShowProgression:Boolean;
F:File;
CurrParam,Source,Target:String;
Begin
P:=0;
ShowProgression:=False;
Source:='';
Target:='';
Repeat
Inc(P);
CurrParam:=ExtractParam(P);
If CurrParam=''Then Begin
If P=1Then Begin
WriteLn('ParamŠtre requis');
End;
Break;
End
Else
If CurrParam='/?'Then Begin
Case Language of
_Germany:Begin
WriteLn('Kopiert eine oder mehrere Dateien an eine andere Position.');
WriteLn;
WriteLn('COPY [/?] [/P] source target');
End;
_English:Begin
WriteLn('Purpose: Copy data between disks, directories or files.');
WriteLn;
WriteLn('Format: COPY [/?] [/P] source target');
End;
Else Begin
WriteLn('COPY Cette commande permet d''effacer la copie de fichier vers un autre emplacement.');
WriteLn;
WriteLn('Syntaxe:');
WriteLn;
WriteLn('COPY [/?] [/P] source destination');
WriteLn;
WriteLn(' /? Ce parametre permet d''afficher l''aide sur cette commande');
WriteLn(' /P Ce parametre permet d''afficher la progression de la copie');
WriteLn('source Ce parametre permet d''indiquer le fichier source');
WriteLn('destination Ce parametre permet d''indiquer le fichier destination');
Exit;
End;
End;
End
Else
If(CurrParam='/P')or(CurrParam='/p')Then ShowProgression:=True
Else
If CurrParam<>''Then
Begin
If Source=''Then Source:=CurrParam
Else Target:=CurrParam;
End;
If P>9Then Break;
Until CurrParam='';
If(Source='')or(Target='')Then Begin
WriteLn('La source et la destination sont requises');
End
Else
Begin
If CopyFile(Source,Target,ShowProgression)Then WriteLn('1 fichier copie')
Else WriteLn('Echec de copie de fichier');
End;
End;
Procedure CTTYCommand;Begin
WriteLn('Cette commande n''est pas mise en oeuvre');
End;
Procedure DateCommand;
Var
FirstParam:String;
Year,Month,Day,DayOfMonth:Word;
Begin
FirstParam:=ExtractParam(1);
If FirstParam='/?'Then Begin
Case Language of
_Germany:Begin
WriteLn('Wechselt das eingestellte Datum oder zeigt es an.');
WriteLn;
WriteLn('DATE [/?]');
End;
_English:Begin
WriteLn('Purpose: Display and optionnally change the system date.');
WriteLn;
WriteLn('Format: DATE [/?]');
End;
Else Begin
WriteLn('DATE Cette commande permet de fixer ou de demander la date du systeme d''exploitation');
WriteLn;
WriteLn('Syntaxe:');
WriteLn;
WriteLn('DATE [/?]');
WriteLn;
WriteLn(' /? Ce paramŠtre permet d''afficher l''aide sur cette commande');
End;
End;
End
Else
Begin
GetDate(Year,Month,Day,DayOfMonth);
If(Pipe)Then WriteLn(PipeFile,'La date du jour est ',Year:4,'-',PadZeroLeft(Month,2),'-',PadZeroLeft(Day,2))
Else WriteLn('La date du jour est ',Year:4,'-',PadZeroLeft(Month,2),'-',PadZeroLeft(Day,2));
End;
End;
Procedure DeleteCommand;
Var
P:Byte;
Err:Word;
F:File;
CurrParam:String;
Begin
P:=0;
Repeat
Inc(P);
CurrParam:=ExtractParam(P);
If CurrParam=''Then Begin
If P=1Then Begin
WriteLn('ParamŠtre requis');
End;
Break;
End
Else
If CurrParam='/?'Then Begin
Case Language of
_Germany:Begin
WriteLn('L”scht eine oder mehrere Dateien.');
WriteLn;
WriteLn('DEL [/?] Datainame');
End;
_English:Begin
WriteLn('Purpose: Erase one file');
WriteLn;
WriteLn('Format: DEL [/?] file');
Exit;
End;
Else Begin
WriteLn('DEL Cette commande permet d''effectuer la suppression de fichier sur un unit‚ de disque.');
WriteLn;
WriteLn('Syntaxe:');
WriteLn;
WriteLn('DEL [/?] fichier');
WriteLn;
WriteLn(' /? Ce paramŠtre permet d''afficher l''aide sur cette commande');
WriteLn(' fichier Ce paramŠtre permet d''indiquer le nom du fichier a supprimer.');
Exit;
End;
End;
End;
{$I-}Assign(F,CurrParam);
Erase(F);
{$I+}
Err:=IoResult;
If Err=0Then WriteLn('1 fichier de supprime')
Else WriteLn(GetErrorMessage(Err));
If P>9Then Break;
Until CurrParam='';
End;
Procedure DirCommand;
Var
P:Byte;
Info:SearchRec;
T:DateTime;
Option:Set of (Pause,Subdirectory,Lower,Brief,Description);
Column:Set Of (Double,Width);
TotalNumFiles,TotalSize:LongInt;
CurrParam,ShowDir,CurrLabel:String;
CurrDrive:Char;
Begin
Option:=[];
Column:=[];
P:=0;
ShowDir:='*.*';
Repeat
Inc(P);
CurrParam:=ExtractParam(P);
If Length(CurrParam)=0Then Break;
If CurrParam='/?'Then Begin
Case Language of
_Germany:Begin
WriteLn('Listet die Dateien und Unterverzeichnisse eines Verzeichnisses auf.');
WriteLn;
WriteLn('Format: DIR [/?] [/2|/W] [/B] [/P] [path]');
End;
_English:Begin
WriteLn('Purpose: Display information about files and subdirectories.');
WriteLn;
WriteLn('Format: DIR [/?] [/2|/W] [/B] [/P] [path]');
Exit;
End;
Else Begin
WriteLn('DIR Cette commande permet d''afficher le contenu d''un repertoire dans l''unit‚ de disque.');
WriteLn;
WriteLn('Syntaxe:');
WriteLn;
WriteLn('DIR [/?] [/2|/W] [/B] [/P] [chemin]');
WriteLn;
WriteLn(' /? Ce parametre permet d''afficher l''aide sur cette commande');
WriteLn(' /2 Ce parametre permet d''afficher sur 2 colonnes');
WriteLn(' /B Ce parametre enleve l''entˆte et les d‚tails de la fin');
WriteLN(' /P Ce parametre affiche une pause apres l''affichage d''une page pleine');
WriteLn(' /W Ce parametre affiche seulement les fichiers sur plein de colonnes');
Exit;
End;
End;
End
Else
If CurrParam='/2'Then Include(Column,Double) Else
If(CurrParam='/B')or(CurrParam='/b')Then Include(Option,Brief) Else
If(CurrParam='/L')or(CurrParam='/l')Then Include(Option,Lower) Else
If(CurrParam='/P')or(CurrParam='/p')Then Include(Option,Pause) Else
If(CurrParam='/W')or(CurrParam='/w')Then Include(Column,Width)
Else ShowDir:=CurrParam;
If P>99Then Break;
Until CurrParam='';
CurrDrive:=Path2Drive(ShowDir);
CurrLabel:=GetDiskLabel(Byte(CurrDrive)-64);
P:=0;
FindFirst(ShowDir,AnyFile,Info);
If(Width)in(Column)Then While DOSError=0 do Begin
Write(PadRight(Info.Name,16));
FindNext(Info);
If(Pause)in(Option)Then Begin
Inc(P);
If P=Hi(WindMax)Then Begin
Write('Presse une touche pour continuer...');
If ReadKey=#27Then Exit;
WriteLn;
P:=0;
End;
End;
End
Else
If(Double)in(Column)Then While DOSError=0 do Begin
Write(PadRight(Info.Name,13));
If Info.Attr and Directory=Directory Then Begin
If(Pipe)Then Write(PipeFile,PadRight('<DIR>',9))
Else Write(PadRight('<DIR>',9));
End
Else
Write(Info.Size:9);
UnpackTime(Info.Time,T);
If(Pipe)Then Begin
Write(PipeFile,' ',T.Year:4,'-',PadZeroLeft(T.Month,2),'-',
PadZeroLeft(T.Day,2),' ',T.Hour:2,':',PadZeroLeft(T.Min,2),' ');
End
Else
Begin
Write(' ',T.Year:4,'-',PadZeroLeft(T.Month,2),'-',PadZeroLeft(T.Day,2),' ',
T.Hour:2,':',PadZeroLeft(T.Min,2),' ');
End;
FindNext(Info);
If(Pause)in(Option)Then Begin
Inc(P);
If P=Hi(WindMax)Then Begin
Write('Presse une touche pour continuer...');
If ReadKey=#27Then Exit;
WriteLn;
P:=0;
End;
End;
End
Else
Begin
TotalNumFiles:=0;
TotalSize:=0;
If Not((Brief)in(Option))Then Begin
Inc(P,2);
If(Pipe)Then Begin
WriteLn(PipeFile,'Le volume de l''unite '+CurrDrive+' est '+CurrLabel);
WriteLn(PipeFile);
End
Else
Begin
WriteLn('Le volume de l''unite '+CurrDrive+' est '+CurrLabel);
WriteLn;
End;
End;
While DOSError=0 do Begin
If(Pipe)Then Write(PipeFile,PadRight(Info.Name,13))
Else Write(PadRight(Info.Name,13));
If Info.Attr and Directory=Directory Then Begin
If(Pipe)Then Write(PipeFile,PadRight('<DIR>',15))
Else Write(PadRight('<DIR>',15));
End
Else
Begin
If(Pipe)Then Write(PipeFile,Info.Size:15)
Else Write(Info.Size:15);
End;
UnpackTime(Info.Time,T);
If(Pipe)Then Begin
WriteLn(PipeFile,' ',T.Year:4,'-',PadZeroLeft(T.Month,2),'-',
PadZeroLeft(T.Day,2),' ',T.Hour:2,':',PadZeroLeft(T.Min,2));
End
Else
Begin
WriteLn(' ',T.Year:4,'-',PadZeroLeft(T.Month,2),'-',
PadZeroLeft(T.Day,2),' ',T.Hour:2,':',PadZeroLeft(T.Min,2));
End;
FindNext(Info);
If(Pause)in(Option)Then Begin
Inc(P);
If P=Hi(WindMax)Then Begin
Write('Presse une touche pour continuer...');
If ReadKey=#27Then Exit;
WriteLn;
P:=0;
End;
End;
Inc(TotalNumFiles);
Inc(TotalSize,Info.Size);
End;
If Not((Brief)in(Option))Then Begin
If(Pipe)Then Begin
WriteLn(PipeFile,' Les ',TotalNumFiles,' fichier(s) utilisent ',TotalSize,' octet(s)');
WriteLn(PipeFile,DiskFree(Byte(CurrDrive)-64):10,' octet(s) de libre');
End
Else
Begin
WriteLn(' Les ',TotalNumFiles,' fichier(s) utilisent ',TotalSize,' octet(s)');
WriteLn(DiskFree(Byte(CurrDrive)-64):10,' octet(s) de libre');
End;
End;
End;
End;
Procedure EchoCommand;
Var
FirstParam:String;
Begin
FirstParam:=ExtractParam(1);
If FirstParam='/?'Then Begin
Case Language of
_Germany:Begin
WriteLn('Zeigt Meldungen an oder schaltet die Befehlsanzeige ein (ON) oder aus (OFF).');
WriteLn;
WriteLn('ECHO [ON | OFF]');
WriteLN('ECHO [Meldung]');
End;
_English:Begin
WriteLn('Purpose: Display a message, enable or disable batch file or command-line');
WriteLn(' ':10,'echoing, or display the echo status.');
WriteLn;
WriteLn('Format: ECHO [ON | OFF | message]');
End;
Else Begin
WriteLn('ECHO Cette commande permet d''activer ou desactiver le prompt de commande ',
'ou d''afficher un message sur le console du systeme d''exploitation.');
WriteLn;
WriteLn('Syntaxe:');
WriteLn;
WriteLn('ECHO [/?] message');
WriteLn('ECHO [OFF|ON]');
WriteLn;
WriteLn(' /? Ce parametre permet d''afficher l''aide sur cette commande');
WriteLn(' message Ce parametre permet d''afficher un message');
WriteLn(' OFF Ce parametre permet de desactiver le prompt.');
WriteLn(' ON Ce parametre permet d''activer le prompt.');
End;
End;
End
Else
If ParamList='.'Then WriteLn Else
If StrToUpper(ParamList)='OFF'Then Echo:=False Else
If StrToUpper(ParamList)='ON'Then Echo:=True
Else WriteLn(ParamList);
End;
Procedure EraseCommand;
Var
P:Byte;
Err:Word;
F:File;
CurrParam:String;
Begin
P:=0;
Repeat
Inc(P);
CurrParam:=ExtractParam(P);
If CurrParam=''Then Begin
If P=1Then Begin
WriteLn('ParamŠtre requis');
End;
Break;
End
Else
If CurrParam='/?'Then Begin
Case Language of
_Germany:Begin
WriteLn('L”scht eine oder mehrere Dateien.');
WriteLn;
WriteLn('ERASE Dateiname [/P]');
End;
_English:Begin
WriteLn('Purpose: Erase one file');
WriteLn;
WriteLn('Format: ERASE [/?] file');
End;
Else Begin
WriteLn('ERASE Cette commande permet d''effectuer la suppression de fichier sur un unit‚ de disque.');
WriteLn;
WriteLn('Syntaxe:');
WriteLn;
WriteLn('ERASE [/?] fichier');
WriteLn;
WriteLn(' /? Ce parametre permet d''afficher l''aide sur cette commande');
WriteLn(' fichier Ce parametre permet d''indiquer le nom du fichier a supprimer.');
End;
End;
Exit;
End;
{$I-}Assign(F,CurrParam);