Permalink
Browse files

lib/libcdb.rb (::open, #reopen): Always open in binary mode.

  • Loading branch information...
1 parent 0db8a85 commit 6fbf42527fc8f3d72c57c95a7f090675b97134ad @blackwinter committed Aug 9, 2012
Showing with 6 additions and 5 deletions.
  1. +1 −0 ChangeLog
  2. +5 −5 lib/libcdb.rb
View
@@ -2,6 +2,7 @@
== 0.0.4 [unreleased]
+* Fixed writing with Ruby 1.9.3 on Windows.
* Fixed leaking CDB pointer when closing reader.
== 0.0.3 [2012-04-02]
View
@@ -13,8 +13,8 @@ class CDB
extend Forwardable
- MODE_READ = 'r' # :nodoc:
- MODE_WRITE = 'w' # :nodoc:
+ MODE_READ = 'r'.freeze # :nodoc:
+ MODE_WRITE = 'w'.freeze # :nodoc:
class << self
@@ -91,7 +91,7 @@ def _open_args(path, mode)
else raise ArgumentError, "illegal access mode #{mode.inspect}"
end
- [klass, args.unshift(File.open(path, mode))]
+ [klass, args.unshift(File.open(path, mode + 'b'))]
end
end
@@ -110,7 +110,7 @@ def initialize(io, mode = MODE_WRITE)
case mode
when MODE_READ then open_read
when MODE_WRITE then open_write
- else raise ArgumentError, "illegal access mode #{mode}"
+ else raise ArgumentError, "illegal access mode #{mode.inspect}"
end
end
@@ -256,7 +256,7 @@ def reopen(new_mode = MODE_READ)
@mode = new_mode
new_mode += '+' if new_mode == MODE_WRITE
- io.reopen(io.path, new_mode)
+ io.reopen(io.path, new_mode + 'b')
end
end

0 comments on commit 6fbf425

Please sign in to comment.