login about faq

Hi,

Is it possible to create a TAR archive containing the files only, instead of archiving the source folder as well.

Regards, Eva

asked May 24 '13 at 05:29

maomea's gravatar image

maomea
112


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");
link

answered May 24 '13 at 08:56

chilkat's gravatar image

chilkat ♦♦
11.8k316358421

Your answer
toggle preview

Follow this question

By Email:

Once you sign in you will be able to subscribe for any updates here

By RSS:

Answers

Answers and Comments

Markdown Basics

  • *italic* or __italic__
  • **bold** or __bold__
  • link:[text](http://url.com/ "title")
  • image?![alt text](/path/img.jpg "title")
  • numbered list: 1. Foo 2. Bar
  • to add a line break simply add two spaces to where you would like the new line to be.
  • basic HTML tags are also supported

Tags:

×17

Asked: May 24 '13 at 05:29

Seen: 822 times

Last updated: May 24 '13 at 08:56

powered by OSQA