-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathSTAT.PAS
71 lines (65 loc) · 1.97 KB
/
STAT.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
{ @author: Sylvain Maltais ([email protected])
@created: 2021
@website(https://www.gladir.com/unix-0)
@abstract(Target: Turbo Pascal, Free Pascal)
}
Program STAT;
Uses DOS;
Var
I:Integer;
Info:SearchRec;
T:DateTime;
Function PadRight(Value:LongInt;Space:Byte):String;
Var
S:String;
Begin
Str(Value,S);
While Length(S)<Space do S:=S+' ';
PadRight:=S;
End;
Function PadZeroLeft(Value:LongInt;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('STAT : Cette commande permet d''afficher des informations sur des fichiers.');
WriteLn;
WriteLn('Syntaxe : STAT fichiers');
End
Else
If ParamCount>0Then Begin
For I:=1 to ParamCount do Begin
FindFirst(ParamStr(I),AnyFile,Info);
While DosError=0 do Begin
If Not((Info.Name='.')or(Info.Name='..'))Then Begin
WriteLn('Fichier: ','''',Info.Name,'''');
WriteLn('Taille: ',PadRight(Info.Size,10),'Blocs: ',(Info.Size shr 9)+Byte((Info.Size and$1FF)>0):10,' ');
UnpackTime(Info.Time,T);
Write('Acces: (');
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('-');
WriteLn(')');
WriteLn('Modifier: ',T.Year:4,'-',PadZeroLeft(T.Month,2),'-',
PadZeroLeft(T.Day,2),' ',T.Hour:2,':',PadZeroLeft(T.Min,2),' ');
End;
FindNext(Info);
End;
End;
End
Else
WriteLn('Parametres requis !');
END.