Hi all-
I’ve been using JUCE for a little while and am currently trying to create a function that creates a zip file from a directory using the Zip_File class. Everything runs smoothly if the directory only contains single files or if I only search for single files and not subdirectories. However, if the directory contains subdirectories and I try to include them in the zipped file, I get the following assertion in FileInputStream::read when I try to write the ZipFile::Builder object to a stream :
Here is my code for trying to zip up the directory, which takes a file to be zipped and outputs a file with a predetermined path:
[code]void eftFile::compress(File tempFolder, File outputZip)
{
ZipFile::Builder zipBuilder;
Array tempFiles;
//find files
tempFolder.findChildFiles(tempFiles, File::findFilesAndDirectories, true, “*”);
//add files to Builder object
for (int i = 0; i < tempFiles.size(); i++)
{
zipBuilder.addFile(tempFiles[i], 9);
}
//save our zip file
double *progress = nullptr;
if (outputZip.exists())
{
outputZip.deleteFile();
}
FileOutputStream os (outputZip);
zipBuilder.writeToStream(os, progress);
}[/code]
The assertion arises when I do writeToStream. I know that there is something very obvious here that I am missing but I haven’t been able to solve it so far, I’m not too familiar with how zip files work. If anyone could let me know what I’m doing wrong or point me in the right direction that would be great, thanks!
-Tom