mirror of
				https://github.com/ruby/ruby.git
				synced 2022-11-09 12:17:21 -05:00 
			
		
		
		
	* ext/dbm/dbm.c (fdbm_closed): new method DBM#closed?
* ext/gdbm/gdbm.c (fgdbm_closed): new method GDBM#closed?
* ext/sdbm/init.c (fsdbm_closed): new method SDBM#closed?
* test/dbm/test_dbm.rb, test/gdbm/test_gdbm.rb, test/sdbm/test_sdbm.rb
  (teardown): close all db objects before deleting data files.
* win32/win32.{ch} (unlink): hook runtime function to change
  file attribute before unlinking.
  fixed: [ruby-dev:26360]
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_1_8@8648 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
			
			
This commit is contained in:
		
							parent
							
								
									150b98fd76
								
							
						
					
					
						commit
						8f8d7c1113
					
				
					 9 changed files with 94 additions and 3 deletions
				
			
		
							
								
								
									
										14
									
								
								ChangeLog
									
										
									
									
									
								
							
							
						
						
									
										14
									
								
								ChangeLog
									
										
									
									
									
								
							|  | @ -1,3 +1,17 @@ | |||
| Mon Jun 20 16:48:36 2005  NAKAMURA Usaku  <usa@ruby-lang.org> | ||||
| 
 | ||||
| 	* ext/dbm/dbm.c (fdbm_closed): new method DBM#closed? | ||||
| 
 | ||||
| 	* ext/gdbm/gdbm.c (fgdbm_closed): new method GDBM#closed? | ||||
| 
 | ||||
| 	* ext/sdbm/init.c (fsdbm_closed): new method SDBM#closed? | ||||
| 
 | ||||
| 	* test/dbm/test_dbm.rb, test/gdbm/test_gdbm.rb, test/sdbm/test_sdbm.rb | ||||
| 	  (teardown): close all db objects before deleting data files. | ||||
| 
 | ||||
| 	* win32/win32.{ch} (unlink): hook runtime function to change | ||||
| 	  file attribute before unlinking. | ||||
| 
 | ||||
| Mon Jun 20 02:15:35 2005  Nobuyoshi Nakada  <nobu@ruby-lang.org> | ||||
| 
 | ||||
| 	* gc.c (define_final): document fix: finalizers never get called | ||||
|  |  | |||
|  | @ -71,6 +71,21 @@ fdbm_close(obj) | |||
|     return Qnil; | ||||
| } | ||||
| 
 | ||||
| static VALUE | ||||
| fdbm_closed(obj) | ||||
|     VALUE obj; | ||||
| { | ||||
|     struct dbmdata *dbmp; | ||||
| 
 | ||||
|     Data_Get_Struct(obj, struct dbmdata, dbmp); | ||||
|     if (dbmp == 0) | ||||
| 	return Qtrue; | ||||
|     if (dbmp->di_dbm == 0) | ||||
| 	return Qtrue; | ||||
| 
 | ||||
|     return Qfalse; | ||||
| } | ||||
| 
 | ||||
| static VALUE fdbm_alloc _((VALUE)); | ||||
| static VALUE | ||||
| fdbm_alloc(klass) | ||||
|  | @ -750,6 +765,7 @@ Init_dbm() | |||
| 
 | ||||
|     rb_define_method(rb_cDBM, "initialize", fdbm_initialize, -1); | ||||
|     rb_define_method(rb_cDBM, "close", fdbm_close, 0); | ||||
|     rb_define_method(rb_cDBM, "closed?", fdbm_closed, 0); | ||||
|     rb_define_method(rb_cDBM, "[]", fdbm_aref, 1); | ||||
|     rb_define_method(rb_cDBM, "fetch", fdbm_fetch_m, -1); | ||||
|     rb_define_method(rb_cDBM, "[]=", fdbm_store, 2); | ||||
|  |  | |||
|  | @ -72,6 +72,21 @@ fgdbm_close(obj) | |||
|     return Qnil; | ||||
| } | ||||
| 
 | ||||
| static VALUE | ||||
| fgdbm_closed(obj) | ||||
|     VALUE obj; | ||||
| { | ||||
|     struct dbmdata *dbmp; | ||||
| 
 | ||||
|     Data_Get_Struct(obj, struct dbmdata, dbmp); | ||||
|     if (dbmp == 0) | ||||
| 	return Qtrue; | ||||
|     if (dbmp->di_dbm == 0) | ||||
| 	return Qtrue; | ||||
| 
 | ||||
|     return Qfalse; | ||||
| } | ||||
| 
 | ||||
| static VALUE fgdbm_s_alloc _((VALUE)); | ||||
| 
 | ||||
| static VALUE | ||||
|  | @ -941,6 +956,7 @@ Init_gdbm() | |||
| 
 | ||||
|     rb_define_method(rb_cGDBM, "initialize", fgdbm_initialize, -1); | ||||
|     rb_define_method(rb_cGDBM, "close", fgdbm_close, 0); | ||||
|     rb_define_method(rb_cGDBM, "closed?", fgdbm_closed, 0); | ||||
|     rb_define_method(rb_cGDBM, "[]", fgdbm_aref, 1); | ||||
|     rb_define_method(rb_cGDBM, "fetch", fgdbm_fetch_m, -1); | ||||
|     rb_define_method(rb_cGDBM, "[]=", fgdbm_store, 2); | ||||
|  |  | |||
|  | @ -62,6 +62,21 @@ fsdbm_close(obj) | |||
|     return Qnil; | ||||
| } | ||||
| 
 | ||||
| static VALUE | ||||
| fsdbm_closed(obj) | ||||
|     VALUE obj; | ||||
| { | ||||
|     struct dbmdata *dbmp; | ||||
| 
 | ||||
|     Data_Get_Struct(obj, struct dbmdata, dbmp); | ||||
|     if (dbmp == 0) | ||||
| 	return Qtrue; | ||||
|     if (dbmp->di_dbm == 0) | ||||
| 	return Qtrue; | ||||
| 
 | ||||
|     return Qfalse; | ||||
| } | ||||
| 
 | ||||
| static VALUE fsdbm_alloc _((VALUE)); | ||||
| static VALUE | ||||
| fsdbm_alloc(klass) | ||||
|  | @ -734,6 +749,7 @@ Init_sdbm() | |||
| 
 | ||||
|     rb_define_method(rb_cDBM, "initialize", fsdbm_initialize, -1); | ||||
|     rb_define_method(rb_cDBM, "close", fsdbm_close, 0); | ||||
|     rb_define_method(rb_cDBM, "closed?", fsdbm_closed, 0); | ||||
|     rb_define_method(rb_cDBM, "[]", fsdbm_aref, 1); | ||||
|     rb_define_method(rb_cDBM, "fetch", fsdbm_fetch_m, -1); | ||||
|     rb_define_method(rb_cDBM, "[]=", fsdbm_store, 2); | ||||
|  |  | |||
|  | @ -42,7 +42,9 @@ if defined? DBM | |||
|     def teardown | ||||
|       assert_nil(@dbm.close) | ||||
|       assert_nil(@dbm_rdonly.close) | ||||
|       GC.start | ||||
|       ObjectSpace.each_object(DBM) do |obj| | ||||
|         obj.close unless obj.closed? | ||||
|       end | ||||
|       File.delete *Dir.glob("tmptest_dbm*").to_a | ||||
|       p Dir.glob("tmptest_dbm*") if $DEBUG | ||||
|     end | ||||
|  |  | |||
|  | @ -39,7 +39,9 @@ if defined? GDBM | |||
|     def teardown | ||||
|       assert_nil(@gdbm.close) | ||||
|       assert_nil(@gdbm_rdonly.close) | ||||
|       GC.start | ||||
|       ObjectSpace.each_object(GDBM) do |obj| | ||||
|         obj.close unless obj.closed? | ||||
|       end | ||||
|       File.delete *Dir.glob("tmptest_gdbm*").to_a | ||||
|       p Dir.glob("tmptest_gdbm*") if $DEBUG | ||||
|     end | ||||
|  |  | |||
|  | @ -12,7 +12,9 @@ class TestSDBM < Test::Unit::TestCase | |||
|   end | ||||
|   def teardown | ||||
|     assert_nil(@sdbm.close) | ||||
|     GC.start | ||||
|     ObjectSpace.each_object(SDBM) do |obj| | ||||
|       obj.close unless obj.closed? | ||||
|     end | ||||
|     File.delete *Dir.glob("tmptest_sdbm*").to_a | ||||
|     p Dir.glob("tmptest_sdbm*") if $DEBUG | ||||
|   end | ||||
|  |  | |||
|  | @ -3433,6 +3433,26 @@ rb_w32_rmdir(const char *path) | |||
|     return ret; | ||||
| } | ||||
| 
 | ||||
| #undef unlink | ||||
| int | ||||
| rb_w32_unlink(const char *path) | ||||
| { | ||||
|     DWORD attr; | ||||
|     int ret; | ||||
|     RUBY_CRITICAL({ | ||||
| 	attr = GetFileAttributes(path); | ||||
| 	if (attr != (DWORD)-1 && (attr & FILE_ATTRIBUTE_READONLY)) { | ||||
| 	    attr &= ~FILE_ATTRIBUTE_READONLY; | ||||
| 	    SetFileAttributes(path, attr); | ||||
| 	} | ||||
| 	ret = unlink(path); | ||||
| 	if (ret < 0 && attr != (DWORD)-1) { | ||||
| 	    SetFileAttributes(path, attr); | ||||
| 	} | ||||
|     }); | ||||
|     return ret; | ||||
| } | ||||
| 
 | ||||
| #if !defined(__BORLANDC__) && !defined(_WIN32_WCE) | ||||
| int | ||||
| rb_w32_isatty(int fd) | ||||
|  |  | |||
|  | @ -128,6 +128,8 @@ extern "C++" { | |||
| #define mkdir(p, m)		rb_w32_mkdir(p, m) | ||||
| #undef rmdir | ||||
| #define rmdir(p)		rb_w32_rmdir(p) | ||||
| #undef unlink | ||||
| #define unlink(p)		rb_w32_unlink(p) | ||||
| 
 | ||||
| #ifdef __MINGW32__ | ||||
| struct timezone { | ||||
|  | @ -191,6 +193,7 @@ extern int rb_w32_isatty(int); | |||
| #endif | ||||
| extern int rb_w32_mkdir(const char *, int); | ||||
| extern int rb_w32_rmdir(const char *); | ||||
| extern int rb_w32_unlink(const char*); | ||||
| 
 | ||||
| #ifdef __BORLANDC__ | ||||
| extern FILE *rb_w32_fopen(const char *, const char *); | ||||
|  |  | |||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue
	
	 usa
						usa