-
Notifications
You must be signed in to change notification settings - Fork 1
/
DOS2UNIX.PAS
47 lines (43 loc) · 1.11 KB
/
DOS2UNIX.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
{ @author: Sylvain Maltais ([email protected])
@created: 2021
@website(https://www.gladir.com/linux-0)
@abstract(Target: Turbo Pascal, Free Pascal)
}
Program DOS2UNIX;
Const
TmpFile='DOS2UNIX.TMP';
Var
SourceText:Text;
TargetData:File {$IFDEF FPC}of Byte{$ENDIF};
CurrLine:String;
BEGIN
If(ParamStr(1)='/?')or(ParamStr(1)='--help')or(ParamStr(1)='-h')Then Begin
Write('DOS2UNIX : Cette commande permet de convertir les sauts de ligne ',
'DOS en saut de ligne UNIX.');
WriteLn;
WriteLn('Syntaxe : DOS2UNIX nomdufichier');
End
Else
If ParamCount=1Then Begin
Assign(SourceText,ParamStr(1));
Reset(SourceText);
Assign(TargetData,TmpFile);
Rewrite(TargetData);
While NOT EOF(SourceText)do Begin
ReadLn(SourceText,CurrLine);
BlockWrite(TargetData,CurrLine[1],Length(CurrLine));
CurrLine:=Chr($0A);
BlockWrite(TargetData,CurrLine[1],1);
End;
Close(TargetData);
Close(SourceText);
{$I-}Assign(SourceText,ParamStr(1));
Erase(SourceText);{$I+}
{$I-}Assign(TargetData,TmpFile);
Rename(TargetData,ParamStr(1));{$I+}
End
Else
Begin
WriteLn('Parametre invalide !');
End;
END.