-
Notifications
You must be signed in to change notification settings - Fork 0
/
LS.PAS
79 lines (74 loc) · 2.46 KB
/
LS.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
{ @author: Sylvain Maltais ([email protected])
@created: 2021
@website(https://www.gladir.com/xenix-0)
@abstract(Target: Turbo Pascal, Free Pascal)
}
Program LS;
Uses DOS;
Var
Option:Set of (_l,_sector,_time);
I:Integer;
Info:SearchRec;
Path:String;
T:DateTime;
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;
BEGIN
If(ParamStr(1)='/?')or(ParamStr(1)='--help')or(ParamStr(1)='-h')or
(ParamStr(1)='/h')or(ParamStr(1)='/H')Then Begin
WriteLn('LS : Cette commande permet d''afficher les fichiers d''un r‚pertoire.');
WriteLn;
WriteLn('Syntaxe : LS [-l] [-s] [-t] [repertoire]');
WriteLn;
WriteLn(' repertoire Ce paramŠtre permet d''indiquer le r‚pertoire … afficher.');
WriteLn(' -l Ce paramŠtre permet d''effectuer un affichage d‚tails');
WriteLn(' -s Ce paramŠtre permet d''afficher le nombre de secteurs');
WriteLn(' -t Ce paramŠtre permet d''afficher le contenu d''un r‚pertoire en ',
'ordre de temps.');
End
Else
Begin
Option:=[];
Path:='*.*';
For I:=1 to ParamCount do Begin
If ParamStr(I)='-l'Then Include(Option,_l) Else
If ParamStr(I)='-s'Then Include(Option,_sector)Else
If ParamStr(I)='-t'Then Include(Option,_time)
Else Path:=ParamStr(I);
End;
FindFirst(Path,AnyFile,Info);
While DosError=0 do Begin
If Not((Info.Name='.')or(Info.Name='..'))Then Begin
If(_l)in(Option)Then Begin { Affiche les attributs? }
If(Info.Attr and Directory=Directory)Then Write('d')
Else Write('-');
If(Info.Attr and ReadOnly=ReadOnly)Then Write('r')
Else Write('w');
If(Info.Attr and SysFile=SysFile)Then Write('s')
Else Write('-');
If(Info.Attr and Hidden=Hidden)Then Write('h')
Else Write('-');
If(Info.Attr and Archive=Archive)Then Write('a')
Else Write('-');
Write(' ');
End;
If(_Sector)in(Option)Then Begin
Write((Info.Size shr 9)+Byte((Info.Size and$1FF)>0):10,' ');
End;
If(_Time)in(Option)Then Begin
UnpackTime(Info.Time,T);
Write(' ',T.Year:4,'-',PadZeroLeft(T.Month,2),'-',PadZeroLeft(T.Day,2),' ',T.Hour:2,':',PadZeroLeft(T.Min,2),' ');
End;
Write(Info.Name);
WriteLn;
End;
FindNext(Info);
End;
End;
END.