Loading...
Select Version
&pagelevel(3)&pagelevel
#include "tstzip.h"
#include "SzpZout.h"
#include <string.h>
#include <stdio.h>
void main() {
// create a CSzpZip object with error reported in rc and log file.
CSzpZip *zip = new CSzpZip(false);
// create a new container (BS2000 format by default)
int rc = zip->OpenZip("MYCONT.ZIP", CSzpZip::updateNew, CSzpZip::defaut);
// add a file to the container
rc = zip->AddFiles("MYFILE.TXT",
CSzpZip::std,
CSzpZip::defaultCompression,
CSzpZip::character,
"MYFILE.TXT"
);
// list the contents of the container
char *pBuf = 0;
int iSize = 0;
int iNumber = 0;
// Get first element and loop while rc = 1;
rc = zip->ListFiles("*", &pBuf, &iSize, CSzpZip::infoSummary, true, false);
while(rc == 1) {
iNumber++;
// do something with buffer
...
delete [] pBuf;
rc = zip->ListFiles("*", &pBuf, &iSize, CSzpZip::infoSummary, true, false);
}
printf("Number of matching files = %d\n", iNumber);
// extract file from the container – extracted file = EXT-MYFILE.TXT
rc = zip->ExtractFiles("*", "EXT-*", CSzpZip::any, CSzpZip::notSpecified,
CSzpZip::std, CSzpZip::keep, false);
// close zip container
rc = zip->CloseZip();
delete zip;
}