Archived Forum Post

Index of archived forum posts

Question:

dirPrefix() - how do you use this?

Nov 09 '12 at 15:36

I would like to tar up the relative path along with the information. For example, using the standard tar command: tar -cvf my.tar vpm1/dm1. This would include the relative path vpm1/dm1 on each item being tarred up, for example:

vpm1/dm1/calgrp1/myfile.txt vpm1/dm1/calgrp2/myfile.txt ...

When using CkTar, and using the addDirRoot(c:/vmpl1/dm1), the contents ends up as: calgrp1/myfile.txt calgrp2/myfile.txt

There is a "method" call dirPrefix() that seems to be a solution, but I don't understand how it can be used since it does not take an argument (i.e. mytar.dirPrefix("vpm1/dm1").

My only other option is to use the path as part of the tar file, i.e. vpm1_dm1.tar and parse the filename before restoring.

Any ideas?

Thanks.


Answer

DirPrefix is a property. In Chilkat's C++ API, string properties have two forms for the getter, and one for the setter:

    void get_DirPrefix(CkString &str);
    const char *dirPrefix(void);
    void put_DirPrefix(const char *newVal);

To set the DirPrefix, call put_DirPrefix. In the case you described above, you would want to set the DirPrefix equal to "vpm1/dm1/".

(To include multiple directory trees in a single TAR archive, call AddDirRoot once per directory tree. The DirPrefix will apply to all.)


Answer

Thanks, that works. I was reading from the online docs and it didn't mention the getXXX / putXXX methods.