Delphi-Projects
60 строк · 1013.0 Байт
1program UWin;
2
3{$APPTYPE CONSOLE}
4
5uses
6SysUtils;
7
8var
9f1, f2: Text;
10s: string;
11
12begin
13if ParamCount = 0 then
14begin
15Writeln('No source file given to convert!');
16Halt(1);
17end;
18
19if not FileExists(ParamStr(1)) then
20begin
21Writeln('No such file exists!');
22Halt(2);
23end;
24
25if ParamCount = 1 then
26begin
27s := ChangeFileExt(ParamStr(1), '.BAK');
28RenameFile(ParamStr(1), s);
29AssignFile(f1, s);
30AssignFile(f2, ParamStr(1));
31end
32else
33begin
34s := ParamStr(2);
35if DirectoryExists(s) then
36s := IncludeTrailingPathDelimiter(s) +
37ExtractFileName(ParamStr(1));
38AssignFile(f1, ParamStr(1));
39AssignFile(f2, s);
40end;
41
42try
43Reset(f1);
44Rewrite(f2);
45while not Eof(f1) do
46begin
47ReadLn(f1, s);
48WriteLn(f2, RWin(TrimRight(s)));
49end;
50finally
51CloseFile(f1);
52CloseFile(f2);
53end;
54
55if ParamCount = 1 then
56DeleteFile(ChangeFileExt(ParamStr(1), '.BAK'))
57else
58DeleteFile(ParamStr(1));
59Halt(0);
60end.
61