[前][次][番号順一覧][スレッド一覧]

ruby-changes:5255

From: nobu <ko1@a...>
Date: Mon, 2 Jun 2008 18:53:18 +0900 (JST)
Subject: [ruby-changes:5255] Ruby:r16754 (trunk): * lib/un.rb (wait_writable): wait until target files can be

nobu	2008-06-02 18:51:30 +0900 (Mon, 02 Jun 2008)

  New Revision: 16754

  Modified files:
    trunk/ChangeLog
    trunk/lib/un.rb
    trunk/win32/Makefile.sub

  Log:
    * 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.


  http://svn.ruby-lang.org/cgi-bin/viewvc.cgi/trunk/lib/un.rb?r1=16754&r2=16753&diff_format=u
  http://svn.ruby-lang.org/cgi-bin/viewvc.cgi/trunk/ChangeLog?r1=16754&r2=16753&diff_format=u
  http://svn.ruby-lang.org/cgi-bin/viewvc.cgi/trunk/win32/Makefile.sub?r1=16754&r2=16753&diff_format=u

Index: ChangeLog
===================================================================
--- ChangeLog	(revision 16753)
+++ ChangeLog	(revision 16754)
@@ -1,3 +1,11 @@
+Mon Jun  2 18:51:15 2008  Nobuyoshi Nakada  <nobu@r...>
+
+	* 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.
+
 Mon Jun  2 16:26:17 2008  Akinori MUSHA  <knu@i...>
 
 	* lib/delegate.rb (Delegator::MethodDelegation#respond_to):
Index: lib/un.rb
===================================================================
--- lib/un.rb	(revision 16753)
+++ lib/un.rb	(revision 16754)
@@ -214,6 +214,33 @@
 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]
Index: win32/Makefile.sub
===================================================================
--- win32/Makefile.sub	(revision 16753)
+++ win32/Makefile.sub	(revision 16754)
@@ -184,6 +184,7 @@
 # Prevents VC++ 2005 (cl ver 14) warnings
 DEFS = -D_CRT_SECURE_NO_DEPRECATE -D_CRT_NONSTDC_NO_DEPRECATE
 MANIFESTTOOL = mt -nologo
+LDSHARED_0 = @$(MINIRUBY) -run -e wait_writable -- -n 10 $@
 LDSHARED_1 = $(MANIFESTTOOL) -manifest $(@).manifest -outputresource:$(@);2
 LDSHARED_2 = @$(RM) $(@:/=\).manifest
 !endif
@@ -610,6 +611,7 @@
 s,@LIBARG@,%s.lib,;t t
 s,@LINK_SO@,$$(LDSHARED) -Fe$$(@) $$(OBJS) $$(LIBS) $$(LOCAL_LIBS) $$(DLDFLAGS) -implib:$$(*F:.so=)-$$(arch).lib -pdb:$$(*F:.so=)-$$(arch).pdb -def:$$(DEFFILE),;t t
 !if $(MSC_VER) >= 1400
+s,@LINK_SO@,@$$(RUBY) -run -e wait_writable -- -n 10 $$(@),;t t
 s,@LINK_SO@,$(MANIFESTTOOL) -manifest $$(@).manifest -outputresource:$$(@);2,;t t
 s,@LINK_SO@,@$$(RM) $$(@:/=\).manifest,;t t
 !endif
@@ -639,7 +641,7 @@
 miniruby$(EXEEXT):
 		@echo. $(LIBS)
 		$(PURIFY) $(CC) $(MAINOBJ) $(MINIOBJS) $(COMMONOBJS) $(DMYEXT) $(LIBS) -Fe$@ $(LDFLAGS)
-		miniruby.exe -v
+		$(LDSHARED_0)
 		$(LDSHARED_1)
 		$(LDSHARED_2)
 
@@ -647,6 +649,7 @@
 $(PROGRAM):	$(MAINOBJ) $(LIBRUBY_SO) $(RUBY_INSTALL_NAME).res
 		$(PURIFY) $(CC) $(MAINOBJ) $(RUBY_INSTALL_NAME).res \
 			$(OUTFLAG)$@ $(LIBRUBYARG) $(LDFLAGS) $(XLDFLAGS)
+		$(LDSHARED_0)
 		$(LDSHARED_1)
 		$(LDSHARED_2)
 !endif
@@ -656,6 +659,7 @@
 		$(PURIFY) $(CC) $(MAINOBJ) $(WINMAINOBJ) \
 			$(RUBYW_INSTALL_NAME).res $(OUTFLAG)$@ $(LIBRUBYARG) \
 			$(LDFLAGS) $(XLDFLAGS) -subsystem:Windows
+		$(LDSHARED_0)
 		$(LDSHARED_1)
 		$(LDSHARED_2)
 !endif
@@ -672,6 +676,7 @@
 		$(LDSHARED) $(MAINOBJ) $(DLDOBJS) $(LIBRUBY_A) \
 			$(RUBY_SO_NAME).res $(LIBS) -Fe$@ $(LDFLAGS) \
 			$(LIBRUBY_DLDFLAGS)
+		$(LDSHARED_0)
 		$(LDSHARED_1)
 		$(LDSHARED_2)
 

--
ML: ruby-changes@q...
Info: http://www.atdot.net/~ko1/quickml/

[前][次][番号順一覧][スレッド一覧]