1
0
Fork 0
mirror of https://github.com/ruby/ruby.git synced 2022-11-09 12:17:21 -05:00

* 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?


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@4993 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
aamine 2003-11-20 10:16:27 +00:00
parent fe411ce245
commit edb9ab1b15
3 changed files with 37 additions and 21 deletions

View file

@ -1,3 +1,14 @@
Thu Nov 20 19:15:50 2003 Minero Aoki <aamine@loveruby.net>
* 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 <nagai@ai.kyutech.ac.jp> Thu Nov 20 17:50:58 2003 Hidetoshi NAGAI <nagai@ai.kyutech.ac.jp>
* ext/tk/sample/tkballoonhelp.rb: new sample script * ext/tk/sample/tkballoonhelp.rb: new sample script

View file

@ -437,7 +437,7 @@ module FileUtils
return if options[:noop] return if options[:noop]
fu_each_src_dest(src, dest) do |s,d| 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 File.unlink d
end end
@ -464,10 +464,10 @@ module FileUtils
alias move mv alias move mv
def cannot_overwrite_file? #:nodoc: def rename_cannot_overwrite_file? #:nodoc:
/djgpp|cygwin|mswin|mingw|bccwin|wince/ === RUBY_PLATFORM /djgpp|cygwin|mswin|mingw|bccwin|wince|emx/ !~ RUBY_PLATFORM
end end
private :cannot_overwrite_file? private :rename_cannot_overwrite_file?
# #
@ -751,7 +751,7 @@ module FileUtils
end end
def have_st_ino? def have_st_ino?
/djgpp|mswin|mingw|bccwin|wince/ !~ RUBY_PLATFORM /mswin|mingw|bccwin|wince|emx/ !~ RUBY_PLATFORM
end end
def fu_stream_blksize( *streams ) def fu_stream_blksize( *streams )

View file

@ -9,19 +9,24 @@ require 'test/unit'
require 'fileasserts' require 'fileasserts'
def windows? def have_drive_letter?
/mswin|mingw|bcc|djgpp/ === RUBY_PLATFORM /djgpp|mswin|mingw|bcc|wince|emx/ === RUBY_PLATFORM
end end
def have_symlink? def have_file_perm?
begin /djgpp|mswin|mingw|bcc|wince|emx/ !~ RUBY_PLATFORM
end
begin
File.symlink 'not_exist', 'symlink_test' File.symlink 'not_exist', 'symlink_test'
return true HAVE_SYMLINK = true
rescue NotImplementedError rescue NotImplementedError
return false HAVE_SYMLINK = false
ensure ensure
File.unlink 'symlink_test' if File.symlink?('symlink_test') File.unlink 'symlink_test' if File.symlink?('symlink_test')
end end
def have_symlink?
HAVE_SYMLINK
end end
@ -103,7 +108,7 @@ class TestFileUtils < Test::Unit::TestCase
assert_equal Dir.pwd, pwd() assert_equal Dir.pwd, pwd()
cwd = Dir.pwd cwd = Dir.pwd
if windows? if have_drive_letter?
cd('C:/') { cd('C:/') {
assert_equal 'C:/', pwd() assert_equal 'C:/', pwd()
} }
@ -338,7 +343,7 @@ end
mkdir 'tmp/tmp', :mode => 0700 mkdir 'tmp/tmp', :mode => 0700
assert_directory 'tmp/tmp' 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' Dir.rmdir 'tmp/tmp'
end end
@ -374,8 +379,8 @@ end
mkdir_p 'tmp/tmp/tmp', :mode => 0700 mkdir_p 'tmp/tmp/tmp', :mode => 0700
assert_directory 'tmp/tmp' assert_directory 'tmp/tmp'
assert_directory 'tmp/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').mode & 0777) if have_file_perm?
assert_equal 0700, (File.stat('tmp/tmp/tmp').mode & 0777) unless windows? assert_equal 0700, (File.stat('tmp/tmp/tmp').mode & 0777) if have_file_perm?
rm_rf 'tmp/tmp' rm_rf 'tmp/tmp'
end end
@ -395,12 +400,12 @@ end
File.open('tmp/bbb', 'w') {|f| f.puts 'bbb' } File.open('tmp/bbb', 'w') {|f| f.puts 'bbb' }
install 'tmp/aaa', 'tmp/bbb', :mode => 0600 install 'tmp/aaa', 'tmp/bbb', :mode => 0600
assert_equal "aaa\n", File.read('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?
t = File.mtime('tmp/bbb') t = File.mtime('tmp/bbb')
install 'tmp/aaa', 'tmp/bbb' install 'tmp/aaa', 'tmp/bbb'
assert_equal "aaa\n", File.read('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') assert_equal t, File.mtime('tmp/bbb')
File.unlink 'tmp/aaa' File.unlink 'tmp/aaa'