Question:
Hi,
Is it possible to create a TAR archive containing the files only, instead of archiving the source folder as well.
Regards, Eva
Yes. For example, the following C++ sample will only TAR the files in "C:aaworkareaxml", not the "c:aaworkareaxml" directory itself:
CkTar tar; MyTarProgress myProgress; tar.put_EventCallbackObject(&myProgress); bool success; // The TAR component will produce a GNU tar 1.13.x format // archive by default. // It is also possible to create PAX -- POSIX 1003.1-2001 format // or USTAR -- POSIX 1003.1-1988 format. // Set the WriteFormat property to "gnu", "pax", or "ustar" to // choose the output TAR format: tar.put_WriteFormat("gnu"); // Add a directory tree to be included in the output TAR archive: success = tar.AddDirRoot("c:/aaworkarea/xml"); if (success != true) { printf("%s\n",tar.lastErrorText()); return; } // Create the TAR archive. // Note: You may use UNC paths, absolute, or relative paths. //success = tar.WriteTarBz2("c:/aaworkarea/x.tar.bz2"); //success = tar.WriteTarGz("c:/aaworkarea/x.tar.gz"); success = tar.WriteTar("c:/aaworkarea/x.tar"); if (success != true) { printf("%s\n",tar.lastErrorText()); return; } printf("%s\n",tar.lastErrorText()); printf("Success.\n");