Reported by JDC:


PNG files read from an mk4vfs can fail to be read.  Likely an issue in vfs::zstreamed in tclvfs.

It happens on non-KitCreator Tclkits too.

<ol>
  <li>
    Create mk4vfs
    <ol>
      <li><tt>$ mkdir
      <li><tt>$ cp cross.png
      <li><tt>$ ./tclkit-8.5.9-linux-i686 sdx.kit wrap
      <li><tt>1 updates
    </ol>
  </li>
  <li>
    Test reading "cross.png" from the mk4vfs
    <ol>
      <li><tt>% vfs::mk4::Mount x

      <li><tt>% cd
      <li><tt>% glob

      <li><tt>% set fd <nowiki>[open

      <li><tt>% fconfigure $fd -translation
      <li><tt>% set data <nowiki>[read $fd]</nowiki>; puts <nowiki>[string length

      <li><tt>% binary scan $data H*

      <li><tt>% puts


    </ol>
  </li>
</ol>


It works in the trivial case posted previously, but fails with the following kit:


In the kit:
<verbatim>
% set fd [open cross.png]
mk7
% fconfigure $fd -encoding binary
% set data [read $fd]; puts [string length $data]
654
% file stat cross.png x
% parray x
x(atime)   = 1285147347
x(blksize) = 135312827
x(blocks)  = 583863729869319636
x(ctime)   = 1285147347
x(dev)     = -143965300
x(gid)     = 0
x(ino)     = 0
x(mode)    = 33279
x(mtime)   = 1285147347
x(nlink)   = 1
x(size)    = 655
x(type)    = file
x(uid)     = 0
</verbatim>

Still not sure where this is failing.

<verbatim>
% mk::loop x db.dirs!90.files { puts "$x, [mk::get $x name]" }
db.dirs!90.files!0, cross.png
db.dirs!90.files!1, tick.png
db.dirs!90.files!2, tclp.gif
% mk::view info db.dirs!90.files
name size:I date:I contents:B
% mk::get db.dirs!90.files!0 size
655
% string length [mk::get db.dirs!90.files!0 contents]
655
% mk::get db.dirs!90.files!0 -size contents
655
%
</verbatim>

Oh, wait I did "-encoding binary" in my second test where it should have been "-translation binary".

Using "-translation binary" causes it to be read correctly.

<verbatim>
% set fd [open cross.png r]
mk7
% fconfigure $fd -translation binary
% set data [read $fd]; puts [string length $data]
655
% binary scan $data H* data_hex
1
</verbatim>

The issue only occurs when using <nowiki>[fcopy]</nowiki> and mk4vfs channels without direct mode.

Simple test:
<verbatim>
vfs::mk4::Mount test.mk /TEST
set fd [open
fconfigure $fd -translation binary
set out [open w]
set ::fcopy_complete 0
proc fcopy_complete {args} { set ::fcopy_complete 1 }
fcopy $fd $out -command fcopy_complete
after 3000
update
puts "FCOPY: $fcopy_complete"
</verbatim>