On Tue, Jan 21, 2014 at 10:45 PM, luciano de souza <luchya...@gmail.com> wrote: > 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?
Probably because Search.Name contains only the filename, but AddFile expects an absolute path (or relative to GetCurrentDir)? > 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, AFAICS all the code is included in the libtar unit. -Flávio _______________________________________________ fpc-pascal maillist - fpc-pascal@lists.freepascal.org http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal