tar icon indicating copy to clipboard operation
tar copied to clipboard

Not enough documentation

Open LoZack19 opened this issue 5 years ago • 3 comments

I like this library, but I would love to read more documentation. In order to be able to use it I needed to read the source code, which could be avoided if there was a good documentation about how to use the function together with some little and explanatory examples.

LoZack19 avatar Mar 11 '21 09:03 LoZack19

Yes, currently, I'm trying to figure out how to extract all the files from a tarball, but this library lacks explanations (such as a man page)

demhademha avatar Aug 14 '21 18:08 demhademha

Hi. The code in this repository was written because I wanted to practice C. I am no longer actively working on it. If you wish to push documentation commits, I will accept them.

If you look at the bottom of main.c, there are examples calls to the various functions.

calccrypto avatar Aug 16 '21 00:08 calccrypto

Yes, currently, I'm trying to figure out how to extract all the files from a tarball, but this library lacks explanations (such as a man page)

int ex_tar(char * tar_file)
{
    char * g[2] = {0};
    int fd;
    struct tar_t * archive = NULL;
    int ret;
    char verbosity = 0;     // 0: no print; 1: print file names; 2: print file properties
    g[0] = tar_file;
    g[1] = NULL;
    fd = open(tar_file, O_RDONLY);

    if (fd == -1)
    {
        return -1;
    }
    // read in data
    if (tar_read(fd, &archive, verbosity) < 0){
        tar_free(archive);
        close(fd);
        return -1;
    }

    ret = tar_extract(fd, archive, 0, (const char**)g, verbosity);
    if (ret < 0)
    {
        close(fd);
        ret = -1;
    }
    close(fd);
    return 0;
}

Schips-Wong avatar Aug 09 '22 08:08 Schips-Wong