[#39671] Ruby 1.8.1 on SX-6 — Masaki Hasegawa <masaki-h@...4u.or.jp>

はじめまして、長谷川 と申します。

16 messages 2004/05/19
[#39673] Re: Ruby 1.8.1 on SX-6 — Tanaka Akira <akr@...17n.org> 2004/05/19

In article <20040519.205107.102564296.suuchi29@naps.kishou.go.jp>,

[ruby-list:39635] Re: open-uri でダウンロードできません

From: Atsushi SHICHI <ats7@...>
Date: 2004-05-06 13:11:51 UTC
List: ruby-list #39635
しちです。

At Thu, 6 May 2004 20:41:37 +0900,
PT2K <PT2K@mymail.to> wrote:

> しかし、残念ながら、
> f.write(h.binmode.read)
> などとしても、正しいバイナリファイルのダウンロードはできないようでした

すみません、こちらでも正しいファイルが出来てませんでした。

とりあえず tempfile.rb に以下の修正を加えたら正しいファイルが
出来るようになりましたが、適切な対処法かは分かりません。

--- lib/tempfile.rb.orig	2003-07-24 01:44:54.000000000 +0900
+++ lib/tempfile.rb	2004-05-06 21:54:34.000000000 +0900
@@ -52,7 +52,7 @@
     @clean_proc = Tempfile.callback(@data)
     ObjectSpace.define_finalizer(self, @clean_proc)
 
-    @tmpfile = File.open(tmpname, File::RDWR|File::CREAT|File::EXCL, 0600)
+    @tmpfile = File.open(tmpname, File::RDWR|File::CREAT|File::EXCL|File::BINARY, 0600)
     @tmpname = tmpname
     @@cleanlist << @tmpname
     @data[1] = @tmpfile
@@ -66,10 +66,10 @@
     Dir.rmdir(lock)
   end
 
-  # Opens or reopens the file with mode "r+".
+  # Opens or reopens the file with mode "rb+".
   def open
     @tmpfile.close if @tmpfile
-    @tmpfile = File.open(@tmpname, 'r+')
+    @tmpfile = File.open(@tmpname, 'rb+')
     @data[1] = @tmpfile
     __setobj__(@tmpfile)
   end

--
Atsushi SHICHI

In This Thread