-
Notifications
You must be signed in to change notification settings - Fork 5
Expand file tree
/
Copy pathTREE.PAS
More file actions
178 lines (168 loc) · 4.84 KB
/
Copy pathTREE.PAS
File metadata and controls
178 lines (168 loc) · 4.84 KB
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
{ @author: Sylvain Maltais (support@gladir.com)
@created: 2022
@website(https://www.gladir.com/msdos0)
@abstract(Target: Turbo Pascal, Free Pascal)
}
Program Tree;
Uses DOS;
Var
Language:(_French,_English,_Germany,_Italian,_Spain,_Albanian,_Portuguese,_Swedish,_Danish,_Japanese);
TmpLanguage:String;
LevelState:Array[0..255]of Boolean;
I:Byte;
Function StrToUpper(S:String):String;
Var
I:Byte; { Compteur de boucle attribue a la chaine de caracteres }
Begin
For I:=1to Length(S)do S[I]:=UpCase(S[I]);
StrToUpper:=S;
End;
Function SetPath4AddFile(Path:String):String;Begin
If Path=''Then GetDir(0,Path);
If Path[Length(Path)]<>'\'Then Path:=Path+'\';
SetPath4AddFile:=Path;
End;
Function Path2Dir(Const Path:String):String;
Var
D:DirStr;
N:NameStr;
E:ExtStr;
Begin
Path2Dir:='';
If Path=''Then Exit;
FSplit(Path,D,N,E);
If E=''Then Begin
If D[Length(D)]<>'\'Then D:=D+'\';
D:=D+E;
End;
If D=''Then Path2Dir:='' Else
If D[Length(D)]<>'\'Then D:=D+'\';
Path2Dir:=D;
End;
Function FindCount(CurrDir:String):Word;
Var
I:Integer;
Rec:SearchRec;
Begin
I:=0;
FindFirst(CurrDir,Directory,Rec);
While DosError=0do Begin
If(Rec.Attr and Directory=Directory)Then Begin
If Not((Rec.Name='.')or(Rec.Name='..')or(Rec.Name=''))Then Begin
Inc(I);
End;
End;
FindNext(Rec);
End;
FindCount:=I;
End;
Procedure ShowTree(Position:Byte;CurrDir:String);
Var
I,CurrEntry,Count:Integer;
Rec:SearchRec;
Begin
Count:=FindCount(CurrDir);
CurrEntry:=0;
FindFirst(CurrDir,Directory,Rec);
While DosError=0do Begin
LevelState[Position]:=CurrEntry+1<Count;
If(Rec.Attr and Directory=Directory)Then Begin
If Not((Rec.Name='.')or(Rec.Name='..')or(Rec.Name=''))Then Begin
Inc(CurrEntry);
For I:=1 to Position do Begin
If LevelState[I]Then Write(' |')
Else Write(' ':4);
End;
If(CurrEntry>=Count)Then WriteLn('+---',Rec.Name)
Else WriteLn('---',Rec.Name);
ShowTree(Position+1,SetPath4AddFile(Path2Dir(CurrDir)+Rec.Name)+'*.*');
End;
End;
FindNext(Rec);
End;
End;
BEGIN
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 Else
If StrToUpper(Copy(TmpLanguage,1,2))='AL'Then Language:=_Albanian Else
If StrToUpper(Copy(TmpLanguage,1,2))='PT'Then Language:=_Portuguese Else
If StrToUpper(Copy(TmpLanguage,1,2))='SV'Then Language:=_Swedish Else
If StrToUpper(Copy(TmpLanguage,1,2))='DA'Then Language:=_Danish Else
If StrToUpper(Copy(TmpLanguage,1,2))='JA'Then Language:=_Japanese;
End;
If(ParamStr(1)='/?')or(ParamStr(1)='--help')or(ParamStr(1)='-h')Then Begin
Case Language of
_Germany:Begin
WriteLn('Zeigt die Verzeichnisstruktur eines Laufwerks oder Pfads grafisch an.');
WriteLn;
WriteLn('TREE [Laufwerk:][Pfad]');
End;
_English:Begin
WriteLn('Grahpically displays the directory structure of a drive or path.');
WriteLn;
WriteLn('TREE [drive:][path]');
End;
_Italian:Begin
WriteLn('Visualizza graficamente la struttura delle directory di un''unità o percorso.');
WriteLn;
WriteLn('TREE [unità:][percorso]');
End;
_Spain:Begin
WriteLn('Muestra gráficamente la estructura de directorios de una unidad o ruta.');
WriteLn;
WriteLn('TREE [unidad:][ruta]');
End;
_Albanian:Begin
WriteLn('Shfaq në mënyrë grafike strukturën e drejtorive të një disku ose shtegu.');
WriteLn;
WriteLn('TREE [disku:][shtegu]');
End;
_Portuguese:Begin
WriteLn('Exibe graficamente a estrutura de diretórios de uma unidade ou caminho.');
WriteLn;
WriteLn('TREE [unidade:][caminho]');
End;
_Swedish:Begin
WriteLn('Visar grafiskt katalogstrukturen för en enhet eller sökväg.');
WriteLn;
WriteLn('TREE [enhet:][sökväg]');
End;
_Danish:Begin
WriteLn('Viser grafisk mappestrukturen for et drev eller sti.');
WriteLn;
WriteLn('TREE [drev:][sti]');
End;
_Japanese:Begin
WriteLn('Doraibu ya pasuuei no direkutori kouzou wo gurafiku hyouji shimasu.');
WriteLn;
WriteLn('TREE [doraibu:][pasuuei]');
End;
Else Begin
WriteLn('TREE : Cette commande permet d''afficher un arbre de repertoire.');
WriteLn;
WriteLn('Syntaxe : TREE [repertoire]');
WriteLn;
End;
End;
End
Else
Begin
For I:=0 to 255 do LevelState[I]:=False;
If ParamCount>1Then WriteLn('Trop de parametre')Else
If ParamCount=1Then Begin
WriteLn(FExpand(ParamStr(1)));
ShowTree(1,FExpand(ParamStr(1)+'*.*'));
End
Else
Begin
WriteLn(FExpand(''));
ShowTree(1,FExpand('*.*'));
End;
End;
END.