diff --git a/ChangeLog b/ChangeLog index 20a97f63b4..4c4c3a862d 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,14 @@ +Thu Nov 20 19:15:50 2003 Minero Aoki + + * lib/fileutils.rb (have_st_ino?): emx (OS/2 with EMX) does not + have st_ino (always 0). [ruby-dev:21972] + + * lib/fileutils.rb (rename_cannot_overwrite_file?): emx does not + allow overwriting files by rename(2). + + * test/fileutils/test_fileutils.rb: windows? -> + have_drive_letter?, have_file_perm? + Thu Nov 20 17:50:58 2003 Hidetoshi NAGAI * ext/tk/sample/tkballoonhelp.rb: new sample script diff --git a/lib/fileutils.rb b/lib/fileutils.rb index 0210e64f07..ee62f5838b 100644 --- a/lib/fileutils.rb +++ b/lib/fileutils.rb @@ -437,7 +437,7 @@ module FileUtils return if options[:noop] fu_each_src_dest(src, dest) do |s,d| - if cannot_overwrite_file? and File.file?(d) + if rename_cannot_overwrite_file? and File.file?(d) File.unlink d end @@ -464,10 +464,10 @@ module FileUtils alias move mv - def cannot_overwrite_file? #:nodoc: - /djgpp|cygwin|mswin|mingw|bccwin|wince/ === RUBY_PLATFORM + def rename_cannot_overwrite_file? #:nodoc: + /djgpp|cygwin|mswin|mingw|bccwin|wince|emx/ !~ RUBY_PLATFORM end - private :cannot_overwrite_file? + private :rename_cannot_overwrite_file? # @@ -751,7 +751,7 @@ module FileUtils end def have_st_ino? - /djgpp|mswin|mingw|bccwin|wince/ !~ RUBY_PLATFORM + /mswin|mingw|bccwin|wince|emx/ !~ RUBY_PLATFORM end def fu_stream_blksize( *streams ) diff --git a/test/fileutils/test_fileutils.rb b/test/fileutils/test_fileutils.rb index d5357ca4c9..fa5bf7b7fc 100644 --- a/test/fileutils/test_fileutils.rb +++ b/test/fileutils/test_fileutils.rb @@ -9,19 +9,24 @@ require 'test/unit' require 'fileasserts' -def windows? - /mswin|mingw|bcc|djgpp/ === RUBY_PLATFORM +def have_drive_letter? + /djgpp|mswin|mingw|bcc|wince|emx/ === RUBY_PLATFORM end +def have_file_perm? + /djgpp|mswin|mingw|bcc|wince|emx/ !~ RUBY_PLATFORM +end + +begin + File.symlink 'not_exist', 'symlink_test' + HAVE_SYMLINK = true +rescue NotImplementedError + HAVE_SYMLINK = false +ensure + File.unlink 'symlink_test' if File.symlink?('symlink_test') +end def have_symlink? - begin - File.symlink 'not_exist', 'symlink_test' - return true - rescue NotImplementedError - return false - ensure - File.unlink 'symlink_test' if File.symlink?('symlink_test') - end + HAVE_SYMLINK end @@ -103,7 +108,7 @@ class TestFileUtils < Test::Unit::TestCase assert_equal Dir.pwd, pwd() cwd = Dir.pwd -if windows? +if have_drive_letter? cd('C:/') { assert_equal 'C:/', pwd() } @@ -338,7 +343,7 @@ end mkdir 'tmp/tmp', :mode => 0700 assert_directory 'tmp/tmp' - assert_equal 0700, (File.stat('tmp/tmp').mode & 0777) unless windows? + assert_equal 0700, (File.stat('tmp/tmp').mode & 0777) if have_file_perm? Dir.rmdir 'tmp/tmp' end @@ -374,8 +379,8 @@ end mkdir_p 'tmp/tmp/tmp', :mode => 0700 assert_directory 'tmp/tmp' assert_directory 'tmp/tmp/tmp' - assert_equal 0700, (File.stat('tmp/tmp').mode & 0777) unless windows? - assert_equal 0700, (File.stat('tmp/tmp/tmp').mode & 0777) unless windows? + assert_equal 0700, (File.stat('tmp/tmp').mode & 0777) if have_file_perm? + assert_equal 0700, (File.stat('tmp/tmp/tmp').mode & 0777) if have_file_perm? rm_rf 'tmp/tmp' end @@ -395,12 +400,12 @@ end File.open('tmp/bbb', 'w') {|f| f.puts 'bbb' } install 'tmp/aaa', 'tmp/bbb', :mode => 0600 assert_equal "aaa\n", File.read('tmp/bbb') - assert_equal 0600, (File.stat('tmp/bbb').mode & 0777) unless windows? + assert_equal 0600, (File.stat('tmp/bbb').mode & 0777) if have_file_perm? t = File.mtime('tmp/bbb') install 'tmp/aaa', 'tmp/bbb' assert_equal "aaa\n", File.read('tmp/bbb') - assert_equal 0600, (File.stat('tmp/bbb').mode & 0777) unless windows? + assert_equal 0600, (File.stat('tmp/bbb').mode & 0777) if have_file_perm? assert_equal t, File.mtime('tmp/bbb') File.unlink 'tmp/aaa'