home *** CD-ROM | disk | FTP | other *** search
/ The Fred Fish Collection 1.5 / ffcollection-1-5-1992-11.iso / ff_disks / 300-399 / ff384.lzh / NorthC / Example2.LZH / Script / unpack.c < prev    next >
C/C++ Source or Header  |  1990-09-10  |  2KB  |  87 lines

  1. /*  (c) 1990 S.Hawtin.
  2.   Permission is granted to copy this file provided
  3.    1) It is not used for commercial gain
  4.    2) This notice is included in all copies
  5.    3) Altered copies are marked as such
  6.  
  7.   No liability is accepted for the contents of the file.
  8.  
  9. */
  10.  
  11. #include "script.h"
  12.  
  13. /* Unpack file for NorthC */
  14. #define NAME_LEN 128
  15. char ThisDir[NAME_LEN];
  16. char ThisDisk[NAME_LEN];
  17.  
  18. char *_WBConsole="con:20/20/600/80/Unpack NorthC 1.2";
  19.  
  20. void
  21. Unpack(dir,name,dest)
  22.     char *dir;
  23.     char *name;
  24.     char *dest;
  25.    {/* Unpack a compressed file */
  26.     char str[128];
  27.  
  28.     sprintf(str,"\"%sc/lharc\" -x -m -a x \"%s%s\" \"%s\"",
  29.                          ThisDisk,dir,name,dest);
  30.     system(str);
  31.     }
  32.  
  33. void
  34. UnpackSingle(name,dest)
  35.     char *name;
  36.     char *dest;
  37.    {/* Unpack the file "name" on a single drive system */
  38.     char from[128];
  39.     char to[128];
  40.  
  41.     sprintf(from,"%s%s",ThisDir,name);
  42.     sprintf(to,"t:%s",name);
  43.     if(copy(from,to)==-1)
  44.        {echo("Copy failed");
  45.         getchar();
  46.         exit(20);
  47.         }
  48.     Unpack("t:",name,dest);
  49.     remove(to);
  50.     }
  51.  
  52. void
  53. main(argc,argv)
  54.     int argc;
  55.     char **argv;
  56.    {/* Unpack the NorthC disks */
  57.     int secondDrive;
  58.  
  59.     /* Work out the name of the disk and the directory */
  60.     findDirs(ThisDir,ThisDisk,NAME_LEN);
  61.  
  62.     /* Now work out if we have got a second drive */
  63.     secondDrive = ask("Have you got a second drive? ");
  64.  
  65.     type("warning");
  66.     if(!ask("Do you want to continue? "))
  67.         exit(20);
  68.  
  69.     if(secondDrive)
  70.        {/* OK do the unpack on a single drive */
  71.         Unpack(ThisDir,"NorthC1.lzh","NorthC:");
  72.         Unpack(ThisDir,"NorthC2.lzh","NorthC:");
  73.         Unpack(ThisDir,"Example1.lzh","NorthC Examples:");
  74.         Unpack(ThisDir,"Example2.lzh","NorthC Examples:");
  75.         }
  76.       else
  77.        {
  78.         UnpackSingle("NorthC1.lzh","NorthC:");
  79.         UnpackSingle("NorthC2.lzh","NorthC:");
  80.         UnpackSingle("Example1.lzh","NorthC Examples:");
  81.         UnpackSingle("Example2.lzh","NorthC Examples:");
  82.         }
  83.  
  84.     echo("All done, please hit <Enter>");
  85.     getchar();
  86.     }
  87.