home *** CD-ROM | disk | FTP | other *** search
/ DP Tool Club 26 / CD_ASCQ_26_1295.iso / vrac / volume_3.zip / IT2.CPP < prev    next >
C/C++ Source or Header  |  1995-10-09  |  4KB  |  137 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(void)
  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.     done = findfirst("*.zip",&ffblk,0);
  49.     if(done)
  50.         {
  51.          clrscr();
  52.          cout << "No Zipped files in current Directory\n";
  53.         }
  54.     else
  55.         {
  56.         while (!done)
  57.             {
  58.             fnsplit(ffblk.ff_name,drive,dir,file,ext);
  59.             stat = mkdir(file);
  60.             if (!stat)
  61.                 {
  62.                 char pkunzip[120] = "pkunzip ";
  63.                 strcat(pkunzip,curdir);
  64.                 strcat(pkunzip,"\\");
  65.                 strcat(pkunzip,ffblk.ff_name);
  66.                 strcat(pkunzip," ");
  67.                 strcat(pkunzip,curdir);
  68.                 strcat(pkunzip,"\\");
  69.                 strcat(pkunzip,file);
  70.                 cout << "Directory " << file << " created\n";
  71.                 cout << "Unzipping Files into it\n";
  72.                                 //************************
  73.                                 //Shells and run pkunzip *
  74.                                 //************************
  75.                 system(pkunzip);
  76.  
  77.                                 // Resets pkunzip array to blanks
  78.                 for(int temp=0;temp < 120;temp++)
  79.                     {
  80.                     pkunzip[temp] = ' ';
  81.                     }
  82.                 }
  83.             else
  84.                 {
  85.                 clrscr();
  86.                 cout << "Unable to create directory " << file << "\n";
  87.                 cout << "For zipped file " << file << ext;
  88.                 Pause(TRUE);
  89.                 }
  90.             done = findnext(&ffblk);
  91.         }
  92.     }
  93. cout << "This program is Freeware\n";
  94. cout << "Written by Marty A. Lineberry\n";
  95. cout << "Compuserve address 102604,1222\n";
  96. cout << "Internet address marty1@rbdc.rbdc.com\n";
  97. cout << "End of Program, press a key\n";
  98. Pause(FALSE);
  99. return 0;
  100. }
  101.  
  102. //*****************************************************************
  103. //Routine to pause until a key is pressed and then to clear buffer
  104. //******************************************************************
  105. void Pause(int t_f)
  106. {
  107. int temp;
  108. if(t_f == TRUE)
  109.     {
  110.     cout << "\nPause Press a Key\n";
  111.     }
  112. while(!kbhit()); //Waits for Key Press
  113. flush_buffer(); //Clears buffer of any Key Pressed including arrow keys
  114. return;
  115. }
  116. //**********************************************************
  117. //* Used to get the current Drive & Directory              *
  118. //**********************************************************
  119. char *Current_Directory(char *path)
  120. {
  121.    strcpy(path, "X:\\");      /* fill string with form of response: X:\ */
  122.    path[0] = 'A' + getdisk();    /* replace X with current drive letter */
  123.    getcurdir(0, path+3);  /* fill rest of string with current directory */
  124.    return(path);
  125. }
  126. //**********************************************************
  127. //********** Flushes Keyboard buffer ***********************
  128. //**********************************************************
  129. void flush_buffer(void)
  130. {
  131. while(kbhit())
  132.     {
  133.     getch();
  134.     }
  135. return;
  136. }
  137.