Method: Uffizzi::FileHelper.lock
- Defined in:
- lib/uffizzi/helpers/file_helper.rb
.lock(path) ⇒ Object
15 16 17 18 19 20 21 22 |
# File 'lib/uffizzi/helpers/file_helper.rb', line 15 def lock(path) dir = File.dirname(path) FileUtils.mkdir_p(dir) unless File.directory?(dir) File.open(path).flock(File::LOCK_EX) if File.exist?(path) yield File.open(path).flock(File::LOCK_UN) end |