1
+ { @author: Sylvain Maltais ([email protected] )
2
+ @created: 2021
3
+ @website(https://www.gladir.com/corail)
4
+ @abstract(Target: Turbo Pascal, Free Pascal)
5
+ }
6
+
7
+ Program FS;
8
+
9
+ Uses Crt,DOS;
10
+
11
+ Var
12
+ P:Byte;
13
+ Info:SearchRec;
14
+ Option:Set of (Pause,Subdirectory,Lower,Brief,Description);
15
+ Column:Set Of (Double,Width);
16
+ TotalNumFiles,TotalSize:LongInt;
17
+ CurrParam,ShowDir,CurrLabel:String;
18
+ CurrDrive:Char;
19
+
20
+ Function PadRight (S:String;Space:Byte):String;
21
+ Var
22
+ I:Byte;
23
+ Begin
24
+ If Length(S)<Space Then For I:=Length(S)+1 to Space do S:=S+' ' ;
25
+ PadRight:=S;
26
+ End ;
27
+
28
+ Function PadZeroLeft (Value :Integer;Space:Byte):String;
29
+ Var
30
+ S:String;
31
+ Begin
32
+ Str(Value ,S);
33
+ While Length(S)<Space do S:=' 0' +S;
34
+ PadZeroLeft:=S;
35
+ End ;
36
+
37
+ Function Path2Drive (Path:String):Char;Begin
38
+ Path:=FExpand(Path);
39
+ Path2Drive:=Path[1 ];
40
+ End ;
41
+
42
+ Function Path2Dir (Const Path:String):String;
43
+ Var
44
+ D:DirStr;
45
+ N:NameStr;
46
+ E:ExtStr;
47
+ Begin
48
+ FSplit(Path,D,N,E);
49
+ If (Length(D)>3 )and (D[Length(D)]=' \' )Then D:=Copy(D,1 ,Length(D)-1 );
50
+ Path2Dir:=D;
51
+ End ;
52
+
53
+ Function GetDiskLabel (Dsk:Byte):String;
54
+ Var
55
+ Info:SearchRec;
56
+ CurrentDir:String;
57
+ Begin
58
+ If Dsk=0Then GetDir(0 ,CurrentDir)
59
+ Else CurrentDir:=Char(Dsk+64 );
60
+ FindFirst(CurrentDir[1 ]+' :\*.*' ,VolumeID,Info);
61
+ While DosError=0do Begin
62
+ If (Info.Attr = VolumeID)Then Begin
63
+ GetDiskLabel:=Info.Name ;
64
+ Exit;
65
+ End ;
66
+ FindNext(Info);
67
+ End ;
68
+ GetDiskLabel:=' '
69
+ End ;
70
+
71
+ BEGIN
72
+ Option:=[];
73
+ Column:=[];
74
+ P:=0 ;
75
+ ShowDir:=' *.*' ;
76
+ Repeat
77
+ Inc(P);
78
+ CurrParam:=ParamStr(P);
79
+ If Length(CurrParam)=0Then Break;
80
+ If CurrParam=' /?' Then Begin
81
+ WriteLn(' FS Cette commande permet d'' afficher la taille d'' un ou plusieurs fichiers.' );
82
+ WriteLn;
83
+ WriteLn(' Syntaxe:' );
84
+ WriteLn;
85
+ WriteLn(' FS [/?] [/P] [chemin]' );
86
+ WriteLn;
87
+ WriteLn(' /? Ce parametre permet d'' afficher l'' aide sur cette commande' );
88
+ WriteLN(' /P Ce parametre affiche une pause apres l'' affichage d'' une page pleine' );
89
+ Exit;
90
+ End
91
+ Else
92
+ If CurrParam=' /2' Then Include(Column,Double) Else
93
+ If (CurrParam=' /P' )or (CurrParam=' /p' )Then Include(Option,Pause)
94
+ Else ShowDir:=CurrParam;
95
+ If P>99Then Break;
96
+ Until CurrParam=' ' ;
97
+ ShowDir:=FExpand(ShowDir);
98
+ CurrDrive:=Path2Drive(ShowDir);
99
+ CurrLabel:=GetDiskLabel(Byte(CurrDrive)-64 );
100
+ P:=0 ;
101
+ FindFirst(ShowDir,AnyFile,Info);
102
+ TotalNumFiles:=0 ;
103
+ TotalSize:=0 ;
104
+ Inc(P,2 );
105
+ WriteLn(Path2Dir(ShowDir));
106
+ WriteLn;
107
+ While DOSError=0 do Begin
108
+ If Not ((Info.Name =' ..' )or (Info.Name =' .' ))Then Begin
109
+ Write(' ' :4 ,PadRight(Info.Name ,13 ));
110
+ If Info.Attr and Directory=Directory Then Begin
111
+ Write(PadRight(' <DIR>' ,15 ));
112
+ End
113
+ Else
114
+ Write(Info.Size:15 ,' octets' );
115
+ WriteLn;
116
+ If (Pause)in (Option)Then Begin
117
+ Inc(P);
118
+ If P=Hi(WindMax)Then Begin
119
+ Write(' Presse une touche pour continuer...' );
120
+ If ReadKey=#27Then Exit;
121
+ WriteLn;
122
+ P:=0 ;
123
+ End ;
124
+ End ;
125
+ Inc(TotalNumFiles);
126
+ Inc(TotalSize,Info.Size);
127
+ End ;
128
+ FindNext(Info);
129
+ End ;
130
+ WriteLn;
131
+ WriteLn(' ' :4 ,TotalSize,' total d'' octet(s) pour ' ,TotalNumFiles,' fichiers' );
132
+ WriteLn(' ' :4 ,' Les ' ,TotalSize,' octet(s) utilise ' ,
133
+ (TotalSize*100 div DiskSize(Byte(CurrDrive)-64 )),' % de l'' espace' );
134
+ WriteLn;
135
+ WriteLn(' Utilisation du disque' );
136
+ WriteLn(DiskSize(Byte(CurrDrive)-64 ):10 ,' octet(s) disponible sur ' ,CurrDrive,' :' );
137
+ WriteLn(DiskFree(Byte(CurrDrive)-64 ):10 ,' octet(s) inutilise sur ' ,CurrDrive,' :, ' ,
138
+ (DiskFree(Byte(CurrDrive)-64 )*100 div DiskSize(Byte(CurrDrive)-64 )),' % est non-utilise' );
139
+ END .
0 commit comments