<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<meta content="text/html; charset=UTF-8" http-equiv="Content-Type">
</head>
<body bgcolor="#ffffff" text="#000000">
Hi Gerald,<br>
<br>
The simple fact is that ZIP files don't store "strings", they only
store bytes. There were a few places in the Compression.pck.st that
still made the old assumption that Strings and ByteArrays were "the
same". I fixed those I found. I also added #addBytes:as:, that is
what you usually want.<br>
<br>
Now, the following examples work:<br>
<br>
ZipArchive new<br>
zipFileComment: 'ZIP file test';<br>
addString: 'ლორემ იფსუმ დოლორ' as: 'someText.bin';<br>
writeToFileNamed: 'someText.zip'.<br>
<br>
ZipArchive new<br>
zipFileComment: 'ZIP file test';<br>
addBytes: 'ლორემ იფსუმ დოლორ' asUtf8Bytes as:
'someTextBytes2.bin';<br>
writeToFileNamed: 'someTextBytes2.zip'.<br>
<br>
Additionally, this example also works:<br>
<br>
ZipArchive new<br>
zipFileComment: 'ZIP file test';<br>
addFile:
'Cuis-Smalltalk-Dev/CoreUpdates/5922-FixedClassMethodPushDown-TomásSpognardi-2023Jul09-20h38m-TS.001.cs.st'
as: 'testOutx.bin';<br>
writeToFileNamed: 'testbinx.zip'.<br>
<br>
So, I guess the problem you had with this file got also fixed along
the way.<br>
<br>
All 3 zip files seem to unzip properly on my Mac.<br>
<br>
Please test again, and keep reporting further problems.<br>
<br>
Cheers,<br>
<br>
On 11/22/2023 8:13 AM, Gerald Klix via Cuis-dev wrote:
<blockquote cite="mid:359d0387-cbe5-c452-6d34-5fcb0c26bb44@klix.ch"
type="cite">
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
Hi Juan,<br>
<br>
I got tried to work around this problem by reading the<br>
license files in binary mode and converting them to a string.<br>
However this leads to as CRC error:<br>
<br>
<tt> extracting: LICENSES.txt bad CRC 46294e2b
(should be c42f8133)</tt><br>
<br>
<br>
As promised I skimmed the ZIP file spec at <tt><a
moz-do-not-send="true" class="moz-txt-link-freetext"
href="https://pkware.cachefly.net/webdocs/casestudies/APPNOTE.TXT">https://pkware.cachefly.net/webdocs/casestudies/APPNOTE.TXT</a></tt><br>
I only saw provisions for UTF-8 file names.<br>
Indeed we have problems storing such files; adding<br>
this one <tt><a moz-do-not-send="true"
class="moz-txt-link-freetext"
href="https://github.com/Cuis-Smalltalk/Cuis-Smalltalk-Dev/blob/master/CoreUpdates/5922-FixedClassMethodPushDown-Tom%C3%A1sSpognardi-2023Jul09-20h38m-TS.001.cs.st">https://github.com/Cuis-Smalltalk/Cuis-Smalltalk-Dev/blob/master/CoreUpdates/5922-FixedClassMethodPushDown-Tom%C3%A1sSpognardi-2023Jul09-20h38m-TS.001.cs.st</a></tt><br>
yields the following error when listing the contents with<tt>
unzip -l</tt><tt><br>
</tt><tt><br>
</tt><tt> 1195 2023-07-19 20:39
Image/CoreUpdates/5922-FixedClassMethodPushDown-TomásSpognardi-2023Jul09-20h38m-TS.001.cs.s</tt><tt><br>
</tt><tt>error: expected central file header signature not found
(file #459).</tt><tt><br>
</tt><tt> (please check that you have transferred or created the
zipfile in the</tt><br>
<br>
<br>
<div class="moz-cite-prefix"><b>The biggest problem however is
this one:<br>
<br>
</b>Execute the following code snippet:<br>
<br>
<tt>'testIn.bin' asFileEntry forceWriteStreamDo: [ :ws |<br>
ws binary.<br>
ws nextPutAll: #[16rF1 16rF7] ].<br>
<br>
<br>
ZipArchive new<br>
zipFileComment: 'ZIP file test';<br>
addFile: 'testIn.bin' as: 'testOut.bin';<br>
writeToFileNamed: 'testbin.zip'<br>
<br>
</tt>Then unzip the file with:<br>
<br>
bear@speedy ~/s/c/Environments> unzip testbin.zip<br>
Archive: testbin.zip<br>
ZIP file test<br>
inflating: testOut.bin<br>
<br>
This yields the following:<br>
<br>
<tt>bear@speedy ~/s/c/Environments> ls -l test*.bin<br>
-rw-r--r-- 1 bear bear 2 Nov 22 12:01 testIn.bin<br>
-rw-rw-rw- 1 bear bear 4 Nov 22 12:01 testOut.bin<br>
<br>
</tt>Invoking <tt>hexdump</tt> on both files shows a "slight"
difference:<br>
<br>
<tt>bear@speedy ~/s/c/Environments> hexdump testIn.bin</tt><tt><br>
</tt><tt>0000000 f7f1 </tt><tt><br>
</tt><tt>0000002</tt><tt><br>
</tt><tt>bear@speedy ~/s/c/Environments> hexdump testOut.bin</tt><tt><br>
</tt><tt>0000000 b1c3 b7c3 </tt><tt><br>
</tt><tt>0000004</tt><br>
<br>
Obviously some UTF8 conversion happened.<br>
Needless to say that <tt>ZipArchive</tt> can't be used to
compress binary<br>
files and thus I can't create a distribution of Haver<br>
with my current tool-set.<br>
<br>
<br>
Best Regards,<br>
<br>
Gerald<br>
<br>
<br>
<br>
On 11/22/23 10:21 AM, Gerald Klix via Cuis-dev wrote:<br>
</div>
<blockquote type="cite"
cite="mid:a929201e-c7f1-76b6-684b-cf4d30e116c8@klix.ch">Thank's
Juan, <br>
<br>
this works now. <br>
<br>
Alas when I tried to create a new Haver release I ran into
another problem. <br>
I also add strings to the ZIP-archive, for example a generated
file that contains <br>
all the contents of all the license files found. The resulting
string contains <br>
Unicode code-points, which makes the CRC computation fail. <br>
<br>
In essence when sending #updateCrc:from:to:in: the primitive
fails – for <br>
obvious reasons – and the failure code kicks in. This in turn
(indirectly) sends #bitXor: <br>
to a UnicodePoint instance, which results in a DNU exception. <br>
<br>
I will try to do some research on how UTF8 data is supposed <br>
to be stored in a ZIP file. <br>
<br>
<br>
Thank's again and Best Regards, <br>
<br>
Gerald <br>
<br>
<br>
<br>
On 11/21/23 9:12 PM, Juan Vuletich wrote: <br>
<blockquote type="cite">On 11/14/2023 10:20 AM, Gerald Klix via
Cuis-dev wrote: <br>
<blockquote type="cite">Hi all, Hi Juan, <br>
<br>
The following snippet does not terminate (within reasonable
time, 20h): <br>
<br>
(z1 := ZipArchive new) zipFileComment: 'ZIP test'. <br>
z1 <br>
addFile: SourceFiles first fileEntry as: 'f1'; <br>
writeToFileNamed: 'test.zip'; <br>
close. <br>
<br>
Adding small test files, created like this: echo test >
test.txt , <br>
however does work: <br>
<br>
(z3 := ZipArchive new) zipFileComment: 'ZIP test'. <br>
z3 <br>
addFile: Smalltalk imageName as: 'f3'; <br>
writeToFileNamed: 'test.zip'; <br>
close. <br>
<br>
<br>
<br>
Best Regards, <br>
<br>
Gerald <br>
</blockquote>
<br>
Hi Gerald, <br>
<br>
I just pushed a fix to GitHub. Thanks for reporting. <br>
<br>
Cheers, <br>
<br>
</blockquote>
<br>
</blockquote>
<br>
</blockquote>
<br>
<br>
<pre class="moz-signature" cols="72">--
Juan Vuletich
cuis.st
github.com/jvuletich
researchgate.net/profile/Juan-Vuletich
independent.academia.edu/JuanVuletich
patents.justia.com/inventor/juan-manuel-vuletich
linkedin.com/in/juan-vuletich-75611b3
twitter.com/JuanVuletich</pre>
</body>
</html>