From 181536b71d1d669448bc581a87aa505e72da8279 Mon Sep 17 00:00:00 2001 From: moguno Date: Sun, 4 May 2014 23:28:51 +0900 Subject: [PATCH] =?UTF-8?q?Windows=E3=81=A7=E3=83=95=E3=82=A1=E3=82=A4?= =?UTF-8?q?=E3=83=AB=E3=81=8C=E5=A3=8A=E3=82=8C=E3=82=8B=E5=95=8F=E9=A1=8C?= =?UTF-8?q?=E3=82=92=E4=BF=AE=E6=AD=A3=E3=80=82=20=E3=83=95=E3=82=A1?= =?UTF-8?q?=E3=82=A4=E3=83=AB=E3=82=92=E9=96=8B=E3=81=8F=E3=81=A8=E3=81=8D?= =?UTF-8?q?=E3=81=AB=E3=83=90=E3=82=A4=E3=83=8A=E3=83=AA=E3=83=A2=E3=83=BC?= =?UTF-8?q?=E3=83=89=E3=81=A7=E9=96=8B=E3=81=8F=E6=A7=98=E3=81=AB=E3=81=97?= =?UTF-8?q?=E3=81=9F=E3=80=82?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- core/service_keeper.rb | 4 ++-- core/utils.rb | 6 +++--- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/core/service_keeper.rb b/core/service_keeper.rb index c1e4432..ccf1905 100644 --- a/core/service_keeper.rb +++ b/core/service_keeper.rb @@ -22,7 +22,7 @@ class Service def accounts @account_data ||= @@service_lock.synchronize do if FileTest.exist? ACCOUNT_FILE - File.open(ACCOUNT_FILE) do |file| + File.open(ACCOUNT_FILE, 'rb') do |file| YAML.load(decrypt(file.read)) end else # 旧データの引き継ぎ @@ -106,7 +106,7 @@ class Service # アカウント情報をファイルに保存する def account_write(account_data = @account_data) FileUtils.mkdir_p File.dirname(ACCOUNT_FILE) - File.open(ACCOUNT_TMP, 'w'.freeze) do |file| + File.open(ACCOUNT_TMP, 'wb'.freeze) do |file| file << encrypt(YAML.dump(account_data)) end FileUtils.mv(ACCOUNT_TMP, ACCOUNT_FILE) account_data end diff --git a/core/utils.rb b/core/utils.rb index b5fa278..f13e918 100644 --- a/core/utils.rb +++ b/core/utils.rb @@ -64,14 +64,14 @@ def gen_counter(count=0, increment=1) # ファイルの内容を文字列に読み込む def file_get_contents(fn) - open(fn, 'r:utf-8'){ |input| + open(fn, 'rb:utf-8'){ |input| input.read } end # 文字列をファイルに書き込む def file_put_contents(fn, body) - File.open(fn, 'w'){ |put| + File.open(fn, 'wb'){ |put| put.write body body } @@ -80,7 +80,7 @@ end # ファイル _fn_ の内容からオブジェクトを読み込む。 # _fn_ は、object_put_contents() で保存されたファイルでなければならない。 def object_get_contents(fn) - File.open(fn, 'r'){ |input| + File.open(fn, 'rb'){ |input| Marshal.load input } end -- 1.9.2