[Cuis-dev] [DEFECT] Can neither write nor read DoubleByteArray instances

Juan Vuletich juan at cuis.st
Sun Jul 30 08:09:34 PDT 2023


Hi Gerald,

The same should happen with WordArray. The issue here is that files are 
byte sequential. Storing multibyte objects requires defining an 
endianess. A double byte array written to a file may be in Big Endian or 
Little Endian format. So, the protocol would need to change. Perhaps 
#nextPutAll:isLittleEndian: or similar.

Cheers,

On 7/30/2023 10:04 AM, Gerald Klix via Cuis-dev wrote:
> Hi all, Hi Juan,
>
> I just found out that I can neither write nor read
> instances of a DoubleByteArray with the new UniFileStream.
>
> The writing issue can be fixed easily by adding:
>
> asUtf8Bytes
>     "Answer me as UTF8 bytes for writing on a UniFileStream."
>
>     ^ self
>
> to DoubleByteArray.
>
> Reading a whole junk into a double byte array
> fails completely, because the #next:into:startingAt:
> tries to do this byte by byte (and fails).
>
>
> Test code:
>
> 'test.bytes' asFileEntry forceWriteStreamDo: [ :stream |
>     stream nextPutAll: (DoubleByteArray with: 4711) ].
>
> 'test.bytes' asFileEntry readStreamDo: [ :stream | | a |
>     a := DoubleByteArray new: 1.
>     a byteSize print.
>     stream next: a byteSize into: a startingAt: 1.
>     a explore ]
>
>
> Best Regards,
>
> Gerald
>
>
> PS: Needless to sya that DoubleWordArray has the same problems.


-- 
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



More information about the Cuis-dev mailing list