From: nobu.nakada@... Date: 2002-10-13T00:44:46+09:00 Subject: [ruby-dev:18507] Re: PStoreのFile.copyの中でErrno::EBADF なかだです。 At Sat, 12 Oct 2002 23:59:14 +0900, WATANABE Hirofumi wrote: > > Windows上だと > > File::copy @filename, backup > > の中でErrno::EBADFになっていて、バックアップファイルが > > 正常に作成されません。 > > flockしたままだと、別にopenしたほうではreadできないようです。 > どうすべきか、ちょっと悩みますね。 単に同じFileでコピーしてrewindしとくってのだとまずいでしょうか。 Index: pstore.rb =================================================================== RCS file: /cvs/ruby/src/ruby/lib/pstore.rb,v retrieving revision 1.15 diff -u -2 -p -r1.15 pstore.rb --- pstore.rb 11 Jul 2002 08:22:14 -0000 1.15 +++ pstore.rb 12 Oct 2002 15:42:59 -0000 @@ -123,5 +123,14 @@ class PStore content = Marshal::dump(@table) if !md5 || size != content.size || md5 != Digest::MD5.digest(content) - File::copy @filename, backup + open(backup, "wb") do |bf| + begin + while true + bf.syswrite file.sysread(File::BUFSIZE) + end + rescue EOFError + end + bf.chmod file.stat.mode + end + file.rewind begin file.write(content) -- --- 僕の前にBugはない。 --- 僕の後ろにBugはできる。 中田 伸悦