Добавил:
Mendeleev
Опубликованный материал нарушает ваши авторские права? Сообщите нам.
Вуз:
Предмет:
Файл:Полищук, Семериков. Системное программирование в UNIX средствами Free Pascal / examples / 11 / unnamed11_2
.pas uses stdio;
(* уЛПРЙТПЧБФШ ЖБКМ f1 Ч ЖБКМ f2
* РТЙ РПНПЭЙ УФБОДБТФОЩИ РТПГЕДХТ ЧЧПДБ/ЧЩЧПДБ
*)
function copyfile(const f1, f2:pchar):integer;
var
inf, outf:pfile;
c:longint;
begin
inf := fopen (f1, 'r');
if inf = nil then
begin
copyfile:=-1;
exit;
end;
outf := fopen (f2, 'w');
if outf = nil then
begin
fclose (inf);
copyfile:=-2;
exit;
end;
c := getc (inf);
while c <> EOF do
begin
putc (c, outf);
c := getc (inf);
end;
fclose (inf);
fclose (outf);
copyfile:=0;
end;
begin
if argc < 3 then
halt (1);
if copyfile (argv[1], argv[2])<>0 then
begin
perror ('copyfile');
halt (1);
end;
end.
(* уЛПРЙТПЧБФШ ЖБКМ f1 Ч ЖБКМ f2
* РТЙ РПНПЭЙ УФБОДБТФОЩИ РТПГЕДХТ ЧЧПДБ/ЧЩЧПДБ
*)
function copyfile(const f1, f2:pchar):integer;
var
inf, outf:pfile;
c:longint;
begin
inf := fopen (f1, 'r');
if inf = nil then
begin
copyfile:=-1;
exit;
end;
outf := fopen (f2, 'w');
if outf = nil then
begin
fclose (inf);
copyfile:=-2;
exit;
end;
c := getc (inf);
while c <> EOF do
begin
putc (c, outf);
c := getc (inf);
end;
fclose (inf);
fclose (outf);
copyfile:=0;
end;
begin
if argc < 3 then
halt (1);
if copyfile (argv[1], argv[2])<>0 then
begin
perror ('copyfile');
halt (1);
end;
end.
Соседние файлы в папке 11