And now for the ZIP version... (attached)
I've tested it with a WinZip 2.0 compatible password protected archive.
sync on
zipfile$ = "media.zip"
myfile$ = "base1.jpg"
pw$ = "WLGfx1234"
succ = ZIP FILE TO FILE(zipfile$,myfile$,pw$)
load image myfile$,1
delete file myfile$
do
paste image 1, 0, 0
text 0,0,"Success = "+str$( succ )
sync
loop
The above code unzips a single file from the password protected archive...
EDIT: Apologise for multiple posts. I got carried away...
The actual function in the plugin for unzipping a file in case anybody is curious, this is it:
EXPORTC int dbUnzipToFile(LPCSTR zipfile, LPCSTR filename, LPCSTR pw)
{
using namespace std;
HZIP hz = OpenZip(zipfile, pw);
ZIPENTRY *ze = new ZIPENTRY;
int index, result;
fstream fs;
if ( FindZipItem(hz, filename, 0, &index, ze) != -1 )
{
// now extract it to a file of the same name
fs.open(filename, ios_base::binary | ios_base::out);
char *buf = new char[ze->unc_size];
UnzipItem(hz, index, buf, ze->unc_size);
fs.write(buf, ze->unc_size);
fs.close();
delete[] buf;
result = ze->unc_size;
}
else
{
result = 0;
}
CloseZip(hz);
delete ze;
return result;
}
Mental arithmetic? Me? (That's for computers) I can't subtract a fart from a plate of beans!
Warning! May contain Nuts!