Error with ZipFile::Builder::WriteToStream()


#1

I’m experiencing an issue with ZipFile::Builder::WriteToStream.

The function returns true and executes successfully under Win10_x64. But returns false in Win7_i386.

I’m compiling a 32-bit console executable in VS2015, platform toolset v140, using Juce library v4.3.1.

Thank you to anyone who can offer any suggestions.

Sample code:

   	ZipFile::Builder zipBuilder;
	File contentsFile = File::getSpecialLocation(File::userDesktopDirectory).getChildFile("test.txt");
	zipBuilder.addFile(contentsFile, 0);
	File outputFile = File::getSpecialLocation(File::userDesktopDirectory).getChildFile("test.zip");
	ScopedPointer <FileOutputStream> os = outputFile.createOutputStream();
	if (os==nullptr)
		NativeMessageBox::showMessageBox(AlertWindow::NoIcon,"Error", "Error creating output stream");	
	bool result = zipBuilder.writeToStream(*os, nullptr);
	if (!result)
		NativeMessageBox::showMessageBox(AlertWindow::NoIcon,"Error", "Error writing to stream");
	os->flush();

#2

Does the contentsFile exist in both cases?


#3

Yes, test.txt exists in the Desktop folder in both cases.


#4

In the case of the function failing, a test.zip file is created, however the file size is 0 bytes.


#5

The function also fails when attempting to write to a MemoryOutputStream instead of a FileOutputStream.


#6

The issues still occurs after upgrading to Juce 5.1.1.

VS2017 also does not solve the issue.


#7

Can you step inside the functions to see exactly where it is failing. Have you tried running your app with admin privileges? We don’t have any windows 7 machines here for us to reproduce.