APIdock / Ruby
/
method

wait_writable

ruby latest stable - Class: Object
wait_writable()
public

Wait until the file becomes writable.

ruby -run -e wait_writable  -- [OPTION] FILE
-n RETRY count to retry
-w SEC each wait time in seconds
-v verbose
# File lib/un.rb, line 249
def wait_writable
 setup("n:w:v") do |argv, options|
 verbose = options[:verbose]
 n = options[:n] and n = Integer(n)
 wait = (wait = options[:w]) ? Float(wait) : 0.2
 argv.each do |file|
 begin
 open(file, "r+b")
 rescue Errno::ENOENT
 break
 rescue Errno::EACCES => e
 raise if n and (n -= 1) <= 0
 if verbose
 puts e
 STDOUT.flush
 end
 sleep wait
 retry
 end
 end
 end
end

AltStyle によって変換されたページ (->オリジナル) /