home *** CD-ROM | disk | FTP | other *** search
/ PC Plus SuperCD (UK) 1999 May / pcp151c.iso / misc / src / install / cpio.c < prev    next >
Encoding:
C/C++ Source or Header  |  1998-05-06  |  1.1 KB  |  51 lines

  1. #include <fcntl.h>
  2. #include <newt.h>
  3. #include <stdio.h>
  4. #include <stdlib.h>
  5. #include <unistd.h>
  6. #include <zlib.h>
  7.  
  8. #include "cpio.h"
  9. #include "install.h"
  10.  
  11. /* librpm.a provides this */
  12. int cpioInstallArchive(gzFile stream, void * mappings,
  13.                int numMappings, void * cb, void * cbData,
  14.                char ** failedFile);
  15.  
  16. struct cpioFileMapping {
  17.     char * archivePath;
  18.     char * fsPath;
  19.     mode_t finalMode;
  20.     uid_t finalUid;
  21.     gid_t finalGid;
  22.     int mapFlags;
  23. };
  24.  
  25. #define CPIO_MAP_PATH           (1 << 0)
  26.  
  27. int installCpioFile(gzFile stream, char * cpioName, char * outName, int inWin) {
  28.     struct cpioFileMapping map;
  29.     int rc;
  30.     char * failedFile;
  31.  
  32.     if (outName) {
  33.     map.archivePath = cpioName;
  34.     map.fsPath = outName;
  35.     map.mapFlags = CPIO_MAP_PATH;
  36.     }
  37.     
  38.     rc = cpioInstallArchive(stream, outName ? &map : NULL, 1, NULL, NULL, 
  39.                 &failedFile);
  40.     if (rc || access(outName, R_OK)) {
  41.     if (inWin)
  42.         newtWinMessage("Error", "Ok", "Cannot find archive member %s.\n", 
  43.                 cpioName);
  44.     else
  45.         printf("Cannot find archive member %s.\n", cpioName);
  46.     return INST_ERROR;
  47.     }
  48.  
  49.     return 0;
  50. }
  51.