[fpc-pascal] Adding files to a tar file
luciano de souza
luchyanus at gmail.com
Wed Jan 22 01:45:21 CET 2014
Hello all,
This code should add all the files of a directory in a tar file.
program e01;
{$mode objfpc}{$H+}
uses
libtar, sysutils;
var
archive: TTarWriter;
search: TSearchRec;
BEGIN
archive := TTarWriter.create('arquivo.tar');
with archive do
begin
try
FindFirst('/home/luciano/Documentos/*', faAnyFile, search);
repeat
if (search.name <> '.') and (search.name <> '..') then
AddFile(search.name);
until FindNext(Search) = 0;
finally
free;
end;
end;
END.
The program compiles, but I got an error. The message says that the
first file of the directory can't be opened.
What is wrong?
My second doubt is: I am running this program in Ubuntu 13.10. If I
run it in Windows, will a external library be necessary or all the
code is included in lib tar unit?
Regards,
--
Luciano de Souza
More information about the fpc-pascal
mailing list