-
Notifications
You must be signed in to change notification settings - Fork 0
/
DELTREE.PAS
112 lines (105 loc) · 2.58 KB
/
DELTREE.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
{ @author: Sylvain Maltais (support@gladir.com)
@created: 2021
@website(https://www.gladir.com/pcdos-0)
@abstract(Target: Turbo Pascal, Free Pascal)
}
Program DELTREE;
Uses Crt,DOS;
Var
Language:(_French,_English,_Germany,_Italian,_Spain);
TmpLanguage:String;
Question:Boolean;
I:Integer;
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;
Procedure DeleteFile(FileName:String);
Var
F:File;
Begin
{$I-}Assign(F,FileName);
Erase(F);
{$I+}
End;
Procedure DeleteTree(Dir:String);
Var
Info:SearchRec;
Begin
FindFirst(Dir+'\*.*',AnyFile,Info);
While DOSError=0do Begin
If Info.Attr and Directory=Directory Then Begin
If(Info.Name<>'.')and(Info.Name<>'..')Then DeleteTree(Dir+'\'+Info.Name);
End
Else
Begin
If(Question)Then Begin
Write('Supprimer ',Info.Name,' (O/N) ? ');
Case ReadKey of
#27:Exit;
'O','o':Begin
DeleteFile(Dir+'\'+Info.Name);
Write('Oui');
End;
Else Write('Non');
End;
WriteLn;
End
Else
DeleteFile(Dir+'\'+Info.Name);
End;
FindNext(Info);
End;
{$I-}RmDir(Dir);{$I+}
END;
BEGIN
{$IFDEF FPC}
{$IFDEF WINDOWS}
SetUseACP(False);
{$ENDIF}
{$ENDIF}
Language:=_French;
TmpLanguage:=GetEnv('LANGUAGE');
If TmpLanguage<>''Then Begin
If TmpLanguage[1]='"'Then TmpLanguage:=Copy(TmpLanguage,2,255);
If StrToUpper(Copy(TmpLanguage,1,2))='EN'Then Language:=_English Else
If StrToUpper(Copy(TmpLanguage,1,2))='GR'Then Language:=_Germany Else
If StrToUpper(Copy(TmpLanguage,1,2))='IT'Then Language:=_Italian Else
If StrToUpper(Copy(TmpLanguage,1,2))='SP'Then Language:=_Spain;
End;
If(ParamStr(1)='/?')or(ParamStr(1)='--help')or(ParamStr(1)='-h')Then Begin
Case Language of
_Germany:Begin
WriteLn('L”scht eine oder mehrere Dateien und Verzeichnisse');
WriteLn;
WriteLn('DELTREE [/Y] [Laufwerk:]Pfad');
WriteLn;
WriteLn('/Y Unterdrckt die Anzeige der Best„tigung, ween ein ');
WriteLn('Unterverzeichnis gel”scht wird.');
End;
Else Begin
Write('DELTREE : Cette commande permet de supprimer un repertoire ',
'avec ses fichiers et repertoire.');
WriteLn;
WriteLn('Syntaxe : DELTREE repertoire [/Y]');
End;
End;
End
Else
If ParamCount>0Then Begin
Question:=False;
For I:=1 to ParamCount do Begin
If(ParamStr(I)='/Y')or(ParamStr(I)='/y')Then Question:=True;
End;
For I:=1 to ParamCount do Begin
If Not((ParamStr(I)='/Y')or(ParamStr(I)='/y'))Then DeleteTree(ParamStr(I));
End;
End
Else
WriteLn('Parametre requis !');
END.