0
RubyZipがバイナリファイルを破損する可能性があることが判明しました。よく見ると、Tempfile
クラスはバイナリファイルを正しく再オープンできないようです。Rubyのバイナリファイルの一時ファイルの破損
require 'tempfile'
tmp = Tempfile.new('test.bin', Dir.getwd)
File.open('test.bin', 'rb') { |h| IO.copy_stream(h, tmp) } # => 2
# 2 is the expected number of bytes
tmp.close
# temporary file (looking in OS) now really IS 2 bytes in size
tmp.open
# temporary file (looking in OS) now is 1 byte in size
tmp.binmode
# temporary file (looking in OS) still has the wrong number of bytes (1)
tmp.read.length # => 1
# And here is the problem I keep bumping into
私が使用しているtest.bin
ファイルは2バイトのみ含まれています:00 1a
を効果を発揮するには、次のスクリプトを取ります。テンポラリファイルの破損後、1バイト:00
が含まれています。それが重要なら私は窓を走らせている。
紛失しているものがありますか?これは意図的な行動ですか?もしそうなら、この振る舞いを防ぐ手段がありますか?
は