home *** CD-ROM | disk | FTP | other *** search
/ DP Tool Club 26 / CD_ASCQ_26_1295.iso / vrac / volume_3.zip / ITC.CPP < prev    next >
C/C++ Source or Header  |  1995-11-02  |  5KB  |  193 lines

  1.  
  2. #include <stdlib.h>
  3. #include <conio.h>
  4. #include <iostream.h>
  5. #include <graphics.h>
  6. #include <string.h>
  7. #include <dos.h>
  8. #include <stdio.h>
  9. #include <bios.h>
  10. #include <ctype.h>
  11. #include <time.h>
  12. #include <math.h>
  13. #include <io.h>
  14. #include <dir.h>
  15. #include <process.h>
  16. #include <sys\stat.h>
  17. #include <fstream.h>
  18. #define TRUE 1
  19. #define FALSE 0
  20.  
  21.  
  22.  
  23.  
  24. //Note
  25. // Has one bug in it, won't pkunzip correctly from the root directory
  26. // The only difference in itc.exe is that it accepts the name of
  27. // a zip file on the command line...like
  28. // itc filename.zip
  29.  
  30. char *Current_Directory(char *path);
  31. void flush_buffer();  //Flushes Keyboard of any a-waiting characters
  32. void Pause(int t_f);  //Pause Function
  33.  
  34. int main(int argc, char **argv)
  35. {
  36. clrscr();
  37. char drive[MAXDRIVE];
  38. char dir[MAXDIR];
  39. char file[MAXFILE];
  40. char ext[MAXEXT];
  41. char curdir[MAXPATH];
  42. char *pkunzip_search;
  43. struct ffblk ffblk;
  44. int done, stat;
  45.  
  46. //Searches all current dos paths for pkunzip
  47. pkunzip_search = searchpath("pkunzip.exe");
  48. if(pkunzip_search == NULL)
  49.     {
  50.     clrscr();
  51.     cout << "PKUNZIP.EXE must be in your dos path!";
  52.     exit(EXIT_FAILURE);
  53.     }
  54.  
  55. //Gets Current Directory & searches for first .zip file
  56. Current_Directory(curdir);
  57.  
  58. if(argc == 2)
  59.     {
  60.     done = findfirst(argv[1],&ffblk,0);
  61.     if(done)
  62.         {
  63.          clrscr();
  64.          cout << "No Zipped files in current Directory\n";
  65.         }
  66.     else
  67.         {
  68.         while (!done)
  69.             {
  70.             fnsplit(ffblk.ff_name,drive,dir,file,ext);
  71.             stat = mkdir(file);
  72.             if (!stat)
  73.                 {
  74.                 char pkunzip2[120] = "pkunzip ";
  75.                 strcat(pkunzip2,curdir);
  76.                 strcat(pkunzip2,"\\");
  77.                 strcat(pkunzip2,ffblk.ff_name);
  78.                 strcat(pkunzip2," ");
  79.                 strcat(pkunzip2,curdir);
  80.                 strcat(pkunzip2,"\\");
  81.                 strcat(pkunzip2,file);
  82.                 cout << "Directory " << file << " created\n";
  83.                 cout << "Unzipping Files into it\n";
  84.                 //************************
  85.                 //Shells and run pkunzip *
  86.                 //************************
  87.                 system(pkunzip2);
  88.                 }
  89.  
  90.             else
  91.                 {
  92.                 clrscr();
  93.                 cout << "Unable to create directory " << file << "\n";
  94.                 cout << "For zipped file " << file << ext;
  95.                 Pause(TRUE);
  96.                 }
  97.             done = findnext(&ffblk);
  98.             }
  99.         }
  100.     }
  101.   else//A1
  102.     {
  103.     done = findfirst("*.zip",&ffblk,0);
  104.     if(done)
  105.         {
  106.          clrscr();
  107.          cout << "No Zipped files in current Directory\n";
  108.         }
  109.     else//A2
  110.         {
  111.         while (!done)
  112.             {
  113.             fnsplit(ffblk.ff_name,drive,dir,file,ext);
  114.             stat = mkdir(file);
  115.             if (!stat)
  116.                 {
  117.                 char pkunzip[120] = "pkunzip ";
  118.                 strcat(pkunzip,curdir);
  119.                 strcat(pkunzip,"\\");
  120.                 strcat(pkunzip,ffblk.ff_name);
  121.                 strcat(pkunzip," ");
  122.                 strcat(pkunzip,curdir);
  123.                 strcat(pkunzip,"\\");
  124.                 strcat(pkunzip,file);
  125.                 cout << "Directory " << file << " created\n";
  126.                 cout << "Unzipping Files into it\n";
  127.                 //************************
  128.                 //Shells and run pkunzip *
  129.                 //************************
  130.                 system(pkunzip);
  131.  
  132.                 // Resets pkunzip array to blanks
  133.                 for(int temp=0;temp < 120;temp++)
  134.                     {
  135.                     pkunzip[temp] = ' ';
  136.                     }
  137.                 }
  138.             else
  139.                 {
  140.                 clrscr();
  141.                 cout << "Unable to create directory " << file << "\n";
  142.                 cout << "For zipped file " << file << ext;
  143.                 Pause(TRUE);
  144.                 }
  145.             done = findnext(&ffblk);
  146.             }//Ends While
  147.         }//Ends Else A2
  148.     }//End Else A1
  149. cout << "This program is Freeware\n";
  150. cout << "Written by Marty A. Lineberry\n";
  151. cout << "Compuserve address 102604,1222\n";
  152. cout << "Internet address marty1@rbdc.rbdc.com\n";
  153. cout << "End of Program, press a key\n";
  154. Pause(FALSE);
  155. return 0;
  156. }
  157.  
  158. //*****************************************************************
  159. //Routine to pause until a key is pressed and then to clear buffer
  160. //******************************************************************
  161. void Pause(int t_f)
  162. {
  163. int temp;
  164. if(t_f == TRUE)
  165.     {
  166.     cout << "\nPause Press a Key\n";
  167.     }
  168. while(!kbhit()); //Waits for Key Press
  169. flush_buffer(); //Clears buffer of any Key Pressed including arrow keys
  170. return;
  171. }
  172. //**********************************************************
  173. //* Used to get the current Drive & Directory              *
  174. //**********************************************************
  175. char *Current_Directory(char *path)
  176. {
  177.    strcpy(path, "X:\\");      /* fill string with form of response: X:\ */
  178.    path[0] = 'A' + getdisk();    /* replace X with current drive letter */
  179.    getcurdir(0, path+3);  /* fill rest of string with current directory */
  180.    return(path);
  181. }
  182. //**********************************************************
  183. //********** Flushes Keyboard buffer ***********************
  184. //**********************************************************
  185. void flush_buffer(void)
  186. {
  187. while(kbhit())
  188.     {
  189.     getch();
  190.     }
  191. return;
  192. }
  193.