To expand on Salem's advice for the zip file stuff, awhile ago I created 2 functions for zip file, with his code troubleshooting assistance. You may want to take a look at the following if it will help any:
Code:
#include "Install.h"
void ZipCheck ( char * FileCheck, char * Name )
{
FILE * Tmp;
if ( ( Tmp = fopen( FileCheck, "r" ) ) == 0 )
{
printf("%s not found, skipping.\n", Name);
}
else
{
/* Nothing */
}
fclose(Tmp);
}
void ZipExtract ( char * SourceFile, char * Destination, char * Name )
{
char * args[6];
args[0] = " -qq "; /* makes unzip.exe quiet */
args[1] = " -C "; /* make unzip.exe noncase-sensative */
args[2] = SourceFile;
args[3] = " -d "; /* create new subdirectory for file(s) */
args[4] = Destination;
args[5] = NULL; /* more output supression to unzip.exe */
printf("Copying..");
spawnv( P_WAIT, "d:\\unzip.exe", args );
printf("\b\b\b\b\b\b\b\b\bCopied - %s\n", Name);
}
For the code example at hand, I am using the unzip program found on this page for some of my C / C++ programs I code that help my emulation hobby along to move faster.
A common way to use the functions:
Code:
#include <stdio.h>
int main ( void )
{
ZipCheck("d:\\directory\\foo.zip", "Foo.zip");
/* arg 1 = zip file, arg 2 = commercial name of zip file */
ZipExtract("d:\\directory\\foo.zip", "c:\\NewDirectory", "Software name");
/* OR */
ZipExtract("d:\\directory\\foo.zip ReadMe.txt", "c:\\Newdirectory\\Docs", "ReadMe File");
return 0;
}
If the zip program at question will not work for you, replace it with another. Manipulate the spawn function setup to work in conjunction with the new zip program.
To even expand further:
Code:
#include <stdio.h>
#include <process.h>
int ZipCheck ( char * FileCheck, char * Name );
int ZipExtract ( char * SourceFile, char * Destination, char * Name );
int main ( void )
{
if ( ZipCheck("c:\\windows\\readme.zip", "ReadMeZip") == 0 )
{
ZipExtract("c:\\windows\\readme.zip",
"c:\\windows\\desktop",
"ReadMe");
}
else
{
printf("Exiting on error");
return 1;
}
return 0;
}
int ZipCheck ( char * FileCheck, char * Name )
{
FILE * Tmp;
if ( ( Tmp = fopen( FileCheck, "r" ) ) == 0 )
{
printf("%s not found, skipping.\n", Name);
return 1;
}
else
{
fclose(Tmp);
return 0;
}
}
int ZipExtract ( char * SourceFile, char * Destination, char * Name )
{
char * args[6];
args[0] = " -qq "; /* makes unzip.exe quiet */
args[1] = " -C "; /* make unzip.exe noncase-sensative */
args[2] = SourceFile;
args[3] = " -d "; /* create new subdirectory for file(s) */
args[4] = Destination;
args[5] = NULL; /* more output supression to unzip.exe */
printf("Copying..");
spawnv( P_WAIT, "c:\\windows\\command\\unzip.exe", args );
printf("\b\b\b\b\b\b\b\b\bCopied - %s\n", Name);
return 0;
}
The above program should work so long as you satisfy it's conditions for working.