09/05/18 11:38:29
>>49
def exclusive_write(path, content)
body = lambda{|f|
f.flock File::LOCK_EX
f.write content
f.truncate f.tell
}
File.open(path, 'r+', &body)
rescue Errno::ENOENT
File.open(path, 'w', &body)
end
自分の過去を掘り返してきたらこんなんが出てきた。
正しいかどうかは…。