diff options
| author | nobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2008-06-02 09:51:30 +0000 |
|---|---|---|
| committer | nobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2008-06-02 09:51:30 +0000 |
| commit | 849cfc481e535c6b9f04ab496200644b7c8c939a (patch) | |
| tree | 22273c9208b146b3e45a9afc3d493d7fb69ce5ea /lib | |
| parent | 543630ffa2ddf4617c5d0205032035e62c41ceaf (diff) | |
| download | ruby-849cfc481e535c6b9f04ab496200644b7c8c939a.tar.gz ruby-849cfc481e535c6b9f04ab496200644b7c8c939a.tar.xz ruby-849cfc481e535c6b9f04ab496200644b7c8c939a.zip | |
* lib/un.rb (wait_writable): wait until target files can be
written actually.
* win32/Makefile.sub (LDSHARED_0, LINK_SO): get rid of failure of
mt.exe.
git-svn-id: http://svn.ruby-lang.org/repos/ruby/trunk@16754 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'lib')
| -rw-r--r-- | lib/un.rb | 27 |
1 files changed, 27 insertions, 0 deletions
@@ -214,6 +214,33 @@ def touch end ## +# Wait until the file becomes writable. +# +# ruby -run -e wait_writable -- [OPTION] FILE +# + +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 + puts e + STDOUT.flush + sleep wait + retry + end + end + end +end + +## # Display help message. # # ruby -run -e help [COMMAND] |
