summaryrefslogtreecommitdiffstats
path: root/isys/cpio.c
blob: 06e41502f04932561b7efd62735cc7535da81dc0 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
#include <fcntl.h>
#include <newt.h>
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include <zlib.h>

#include "cpio.h"

int installCpioFile(FD_t fd, char * cpioName, char * outName, int inWin) {
    struct cpioFileMapping map;
    int rc;
    char * failedFile;
    CFD_t cfdbuf, *cfd = &cfdbuf;

    if (outName) {
	map.archivePath = cpioName;
	map.fsPath = outName;
	map.mapFlags = CPIO_MAP_PATH;
    }

    cfd->cpioIoType = cpioIoTypeGzFd;
    cfd->cpioGzFd = gzdFdopen(fdDup(fdFileno(fd)), "r");
    
    rc = cpioInstallArchive(cfd, outName ? &map : NULL, 1, NULL, NULL, 
			    &failedFile);
    gzdClose(cfd->cpioGzFd);

    if (rc || access(outName, R_OK)) {
	return -1;
    }

    return 0;
}