バグ #659 » 0001-Windows.patch
core/service_keeper.rb | ||
---|---|---|
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
|
||
# 旧データの引き継ぎ
|
||
... | ... | |
# アカウント情報をファイルに保存する
|
||
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
|
core/utils.rb | ||
---|---|---|
# ファイルの内容を文字列に読み込む
|
||
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
|
||
}
|
||
... | ... | |
# ファイル _fn_ の内容からオブジェクトを読み込む。
|
||
# _fn_ は、object_put_contents() で保存されたファイルでなければならない。
|
||
def object_get_contents(fn)
|
||
File.open(fn, 'r'){ |input|
|
||
File.open(fn, 'rb'){ |input|
|
||
Marshal.load input
|
||
}
|
||
end
|