home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
DP Tool Club 26
/
CD_ASCQ_26_1295.iso
/
vrac
/
volume_3.zip
/
ITC.ZIP
/
IT2.CPP
next >
Wrap
C/C++ Source or Header
|
1995-10-09
|
4KB
|
137 lines
#include <stdlib.h>
#include <conio.h>
#include <iostream.h>
#include <graphics.h>
#include <string.h>
#include <dos.h>
#include <stdio.h>
#include <bios.h>
#include <ctype.h>
#include <time.h>
#include <math.h>
#include <io.h>
#include <dir.h>
#include <process.h>
#include <sys\stat.h>
#include <fstream.h>
#define TRUE 1
#define FALSE 0
char *Current_Directory(char *path);
void flush_buffer(); //Flushes Keyboard of any a-waiting characters
void Pause(int t_f); //Pause Function
int main(void)
{
clrscr();
char drive[MAXDRIVE];
char dir[MAXDIR];
char file[MAXFILE];
char ext[MAXEXT];
char curdir[MAXPATH];
char *pkunzip_search;
struct ffblk ffblk;
int done, stat;
//Searches all current dos paths for pkunzip
pkunzip_search = searchpath("pkunzip.exe");
if(pkunzip_search == NULL)
{
clrscr();
cout << "PKUNZIP.EXE must be in your dos path!";
exit(EXIT_FAILURE);
}
//Gets Current Directory & searches for first .zip file
Current_Directory(curdir);
done = findfirst("*.zip",&ffblk,0);
if(done)
{
clrscr();
cout << "No Zipped files in current Directory\n";
}
else
{
while (!done)
{
fnsplit(ffblk.ff_name,drive,dir,file,ext);
stat = mkdir(file);
if (!stat)
{
char pkunzip[120] = "pkunzip ";
strcat(pkunzip,curdir);
strcat(pkunzip,"\\");
strcat(pkunzip,ffblk.ff_name);
strcat(pkunzip," ");
strcat(pkunzip,curdir);
strcat(pkunzip,"\\");
strcat(pkunzip,file);
cout << "Directory " << file << " created\n";
cout << "Unzipping Files into it\n";
//************************
//Shells and run pkunzip *
//************************
system(pkunzip);
// Resets pkunzip array to blanks
for(int temp=0;temp < 120;temp++)
{
pkunzip[temp] = ' ';
}
}
else
{
clrscr();
cout << "Unable to create directory " << file << "\n";
cout << "For zipped file " << file << ext;
Pause(TRUE);
}
done = findnext(&ffblk);
}
}
cout << "This program is Freeware\n";
cout << "Written by Marty A. Lineberry\n";
cout << "Compuserve address 102604,1222\n";
cout << "Internet address marty1@rbdc.rbdc.com\n";
cout << "End of Program, press a key\n";
Pause(FALSE);
return 0;
}
//*****************************************************************
//Routine to pause until a key is pressed and then to clear buffer
//******************************************************************
void Pause(int t_f)
{
int temp;
if(t_f == TRUE)
{
cout << "\nPause Press a Key\n";
}
while(!kbhit()); //Waits for Key Press
flush_buffer(); //Clears buffer of any Key Pressed including arrow keys
return;
}
//**********************************************************
//* Used to get the current Drive & Directory *
//**********************************************************
char *Current_Directory(char *path)
{
strcpy(path, "X:\\"); /* fill string with form of response: X:\ */
path[0] = 'A' + getdisk(); /* replace X with current drive letter */
getcurdir(0, path+3); /* fill rest of string with current directory */
return(path);
}
//**********************************************************
//********** Flushes Keyboard buffer ***********************
//**********************************************************
void flush_buffer(void)
{
while(kbhit())
{
getch();
}
return;
}