home *** CD-ROM | disk | FTP | other *** search
/ Power-Programmierung / CD2.mdf / gnu / djgpp / utils / install / unzip.h < prev    next >
Encoding:
Text File  |  1993-11-21  |  2.2 KB  |  78 lines

  1. unzip(FileEntry *fe, int do_unzip)
  2. {
  3.   static int chose_zipv = 0;
  4.   struct ffblk f;
  5.   int i, done;
  6.   int show_error = 1;
  7.   strcpy(default_fptr, fe->file_name);
  8.   while (1)
  9.   {
  10.     struct stat s;
  11.  
  12.     printf("\nInstalling %s\n", default_dir);
  13.  
  14.     if (stat(default_dir, &s) == 0)
  15.       if ((s.st_mode & S_IFMT) == S_IFREG)
  16.         break;
  17.  
  18.     if (show_error)
  19.       printf("\nCannot open file %s.  It should be on disk %d\n", default_dir, fe->disk_no);
  20.     show_error = 1;
  21.     switch (select(0, "Select :", "Inserted new disk", "Select another directory",
  22.                                  "List that directory", "Skip", "Quit", 0))
  23.     {
  24.       case 1:
  25.         break;
  26.       case 2:
  27.         *default_fptr = 0;
  28.         query("Directory to get files from : ", default_dir, default_dir);
  29.         default_fptr = default_dir + strlen(default_dir);
  30.         if (default_fptr > default_dir)
  31.           if (default_fptr[-1] != '\\' && default_fptr[-1] != '/' && default_fptr[-1] != ':')
  32.             *default_fptr++ = '\\';
  33.         strcpy(default_fptr, fe->file_name);
  34.         break;
  35.       case 3:
  36.         strcpy(default_fptr, "*.*");
  37.         printf("\nListing of %s\n", default_dir);
  38.         done = findfirst(default_dir, &f, FA_ARCH | FA_RDONLY | FA_DIREC);
  39.         i = 0;
  40.         while (!done)
  41.         {
  42.           if (f.ff_attrib & FA_DIREC)
  43.             printf("       [%s]%*c", f.ff_name, 12-strlen(f.ff_name), ' ');
  44.           else
  45.           {
  46.             strlwr(f.ff_name);
  47.             printf("%s  %-12s  ", kb(f.ff_fsize), f.ff_name);
  48.           }
  49.           if (++i == 3)
  50.           {
  51.             putchar('\n');
  52.             i = 0;
  53.           }
  54.           else
  55.             fputs("  |  ", stdout);
  56.           done = findnext(&f);
  57.         }
  58.         if (i)
  59.           putchar('\n');
  60.         putchar('\n');
  61.         show_error = 0;
  62.         break;
  63.       case 4:
  64.         return;
  65.       case 5:
  66.         exit(0);
  67.     }
  68.   }
  69.  
  70.   if (!chose_zipv)
  71.     chose_zipv = yesno("Would you like to see the files as they are unzipped");
  72.  
  73.   if (do_unzip)
  74.     spawnlp(P_WAIT, "unzip-dj.exe", "unzip-dj.exe", (chose_zipv=='y') ? "-o" : "-o -qq", default_dir, 0);
  75.   else
  76.     copyfile(default_dir, fe->file_name);
  77. }
  78.