home *** CD-ROM | disk | FTP | other *** search
/ DP Tool Club 26 / CD_ASCQ_26_1295.iso / vrac / volume_3.zip / ITC.ZIP / ITC.CPP < prev    next >
C/C++ Source or Header  |  1995-10-16  |  4KB  |  184 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. char *Current_Directory(char *path);
  22. void flush_buffer();  //Flushes Keyboard of any a-waiting characters
  23. void Pause(int t_f);  //Pause Function
  24.  
  25. int main(int argc, char **argv)
  26. {
  27. clrscr();
  28. char drive[MAXDRIVE];
  29. char dir[MAXDIR];
  30. char file[MAXFILE];
  31. char ext[MAXEXT];
  32. char curdir[MAXPATH];
  33. char *pkunzip_search;
  34. struct ffblk ffblk;
  35. int done, stat;
  36.  
  37. //Searches all current dos paths for pkunzip
  38. pkunzip_search = searchpath("pkunzip.exe");
  39. if(pkunzip_search == NULL)
  40.     {
  41.     clrscr();
  42.     cout << "PKUNZIP.EXE must be in your dos path!";
  43.     exit(EXIT_FAILURE);
  44.     }
  45.  
  46. //Gets Current Directory & searches for first .zip file
  47. Current_Directory(curdir);
  48.  
  49. if(argc == 2)
  50.     {
  51.     done = findfirst(argv[1],&ffblk,0);
  52.     if(done)
  53.         {
  54.          clrscr();
  55.          cout << "No Zipped files in current Directory\n";
  56.         }
  57.     else
  58.         {
  59.         while (!done)
  60.             {
  61.             fnsplit(ffblk.ff_name,drive,dir,file,ext);
  62.             stat = mkdir(file);
  63.             if (!stat)
  64.                 {
  65.                 char pkunzip2[120] = "pkunzip ";
  66.                 strcat(pkunzip2,curdir);
  67.                 strcat(pkunzip2,"\\");
  68.                 strcat(pkunzip2,ffblk.ff_name);
  69.                 strcat(pkunzip2," ");
  70.                 strcat(pkunzip2,curdir);
  71.                 strcat(pkunzip2,"\\");
  72.                 strcat(pkunzip2,file);
  73.                 cout << "Directory " << file << " created\n";
  74.                 cout << "Unzipping Files into it\n";
  75.                 //************************
  76.                 //Shells and run pkunzip *
  77.                 //************************
  78.                 system(pkunzip2);
  79.                 }
  80.  
  81.             else
  82.                 {
  83.                 clrscr();
  84.                 cout << "Unable to create directory " << file << "\n";
  85.                 cout << "For zipped file " << file << ext;
  86.                 Pause(TRUE);
  87.                 }
  88.             done = findnext(&ffblk);
  89.             }
  90.         }
  91.     }
  92.   else//A1
  93.     {
  94.     done = findfirst("*.zip",&ffblk,0);
  95.     if(done)
  96.         {
  97.          clrscr();
  98.          cout << "No Zipped files in current Directory\n";
  99.         }
  100.     else//A2
  101.         {
  102.         while (!done)
  103.             {
  104.             fnsplit(ffblk.ff_name,drive,dir,file,ext);
  105.             stat = mkdir(file);
  106.             if (!stat)
  107.                 {
  108.                 char pkunzip[120] = "pkunzip ";
  109.                 strcat(pkunzip,curdir);
  110.                 strcat(pkunzip,"\\");
  111.                 strcat(pkunzip,ffblk.ff_name);
  112.                 strcat(pkunzip," ");
  113.                 strcat(pkunzip,curdir);
  114.                 strcat(pkunzip,"\\");
  115.                 strcat(pkunzip,file);
  116.                 cout << "Directory " << file << " created\n";
  117.                 cout << "Unzipping Files into it\n";
  118.                 //************************
  119.                 //Shells and run pkunzip *
  120.                 //************************
  121.                 system(pkunzip);
  122.  
  123.                 // Resets pkunzip array to blanks
  124.                 for(int temp=0;temp < 120;temp++)
  125.                     {
  126.                     pkunzip[temp] = ' ';
  127.                     }
  128.                 }
  129.             else
  130.                 {
  131.                 clrscr();
  132.                 cout << "Unable to create directory " << file << "\n";
  133.                 cout << "For zipped file " << file << ext;
  134.                 Pause(TRUE);
  135.                 }
  136.             done = findnext(&ffblk);
  137.             }//Ends While
  138.         }//Ends Else A2
  139.     }//End Else A1
  140. cout << "This program is Freeware\n";
  141. cout << "Written by Marty A. Lineberry\n";
  142. cout << "Compuserve address 102604,1222\n";
  143. cout << "Internet address marty1@rbdc.rbdc.com\n";
  144. cout << "End of Program, press a key\n";
  145. Pause(FALSE);
  146. return 0;
  147. }
  148.  
  149. //*****************************************************************
  150. //Routine to pause until a key is pressed and then to clear buffer
  151. //******************************************************************
  152. void Pause(int t_f)
  153. {
  154. int temp;
  155. if(t_f == TRUE)
  156.     {
  157.     cout << "\nPause Press a Key\n";
  158.     }
  159. while(!kbhit()); //Waits for Key Press
  160. flush_buffer(); //Clears buffer of any Key Pressed including arrow keys
  161. return;
  162. }
  163. //**********************************************************
  164. //* Used to get the current Drive & Directory              *
  165. //**********************************************************
  166. char *Current_Directory(char *path)
  167. {
  168.    strcpy(path, "X:\\");      /* fill string with form of response: X:\ */
  169.    path[0] = 'A' + getdisk();    /* replace X with current drive letter */
  170.    getcurdir(0, path+3);  /* fill rest of string with current directory */
  171.    return(path);
  172. }
  173. //**********************************************************
  174. //********** Flushes Keyboard buffer ***********************
  175. //**********************************************************
  176. void flush_buffer(void)
  177. {
  178. while(kbhit())
  179.     {
  180.     getch();
  181.     }
  182. return;
  183. }
  184.