mirror of
https://github.com/ruby/ruby.git
synced 2022-11-09 12:17:21 -05:00
* lib/fileutils.rb (rm_r): use lchown(2), not chown(2). [ruby-dev:26226]
* lib/fileutils.rb (cd): remove :noop option. (FEATURE CHANGE) * lib/fileutils.rb (cp_r): should copy symlink as symlink, for also tree root. (FEATURE CHANGE) * lib/fileutils.rb (cp_r): new option :dereference_root. * lib/fileutils.rb: new method remove_entry. * lib/fileutils.rb: new method remove_entry_secure. * lib/fileutils.rb: add documentation. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@8525 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
parent
87cad12ae8
commit
55ec2ad163
3 changed files with 601 additions and 409 deletions
18
ChangeLog
18
ChangeLog
|
@ -1,3 +1,21 @@
|
||||||
|
Thu May 26 07:39:07 2005 Minero Aoki <aamine@loveruby.net>
|
||||||
|
|
||||||
|
* lib/fileutils.rb (rm_r): use lchown(2), not chown(2).
|
||||||
|
[ruby-dev:26226]
|
||||||
|
|
||||||
|
* lib/fileutils.rb (cd): remove :noop option. (feature change)
|
||||||
|
|
||||||
|
* lib/fileutils.rb (cp_r): should copy symlink as symlink, for
|
||||||
|
also tree root. (feature change)
|
||||||
|
|
||||||
|
* lib/fileutils.rb (cp_r): new option :dereference_root.
|
||||||
|
|
||||||
|
* lib/fileutils.rb: new method remove_entry.
|
||||||
|
|
||||||
|
* lib/fileutils.rb: new method remove_entry_secure.
|
||||||
|
|
||||||
|
* lib/fileutils.rb: add documentation.
|
||||||
|
|
||||||
Thu May 26 06:08:11 2005 Hidetoshi NAGAI <nagai@ai.kyutech.ac.jp>
|
Thu May 26 06:08:11 2005 Hidetoshi NAGAI <nagai@ai.kyutech.ac.jp>
|
||||||
|
|
||||||
* ext/tk/lib/tk.rb: add shortcut-methods of tk_call + tk_split_list
|
* ext/tk/lib/tk.rb: add shortcut-methods of tk_call + tk_split_list
|
||||||
|
|
931
lib/fileutils.rb
931
lib/fileutils.rb
File diff suppressed because it is too large
Load diff
|
@ -23,30 +23,38 @@ def have_file_perm?
|
||||||
/djgpp|mswin|mingw|bcc|wince|emx/ !~ RUBY_PLATFORM
|
/djgpp|mswin|mingw|bcc|wince|emx/ !~ RUBY_PLATFORM
|
||||||
end
|
end
|
||||||
|
|
||||||
begin
|
$fileutils_rb_have_symlink = nil
|
||||||
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?
|
def have_symlink?
|
||||||
HAVE_SYMLINK
|
if $fileutils_rb_have_symlink == nil
|
||||||
|
$fileutils_rb_have_symlink = check_have_symlink?
|
||||||
|
end
|
||||||
|
$fileutils_rb_have_symlink
|
||||||
end
|
end
|
||||||
|
|
||||||
begin
|
def check_have_symlink?
|
||||||
File.open('linktmp', 'w') {|f| f.puts 'dummy' }
|
File.symlink nil, nil
|
||||||
File.link 'linktmp', 'linktest'
|
rescue NotImplementedError
|
||||||
HAVE_HARDLINK = true
|
return false
|
||||||
rescue NotImplementedError, SystemCallError
|
rescue
|
||||||
HAVE_HARDLINK = false
|
return true
|
||||||
ensure
|
|
||||||
File.unlink 'linktest' if File.exist?('linktest')
|
|
||||||
File.unlink 'linktmp' if File.exist?('linktmp')
|
|
||||||
end
|
end
|
||||||
|
|
||||||
|
$fileutils_rb_have_hardlink = nil
|
||||||
|
|
||||||
def have_hardlink?
|
def have_hardlink?
|
||||||
HAVE_HARDLINK
|
if $fileutils_rb_have_hardlink == nil
|
||||||
|
$fileutils_rb_have_hardlink = check_have_hardlink?
|
||||||
|
end
|
||||||
|
$fileutils_rb_have_hardlink
|
||||||
|
end
|
||||||
|
|
||||||
|
def check_have_hardlink?
|
||||||
|
File.link nil, nil
|
||||||
|
rescue NotImplementedError
|
||||||
|
return false
|
||||||
|
rescue
|
||||||
|
return true
|
||||||
end
|
end
|
||||||
|
|
||||||
begin
|
begin
|
||||||
|
@ -260,8 +268,8 @@ end
|
||||||
assert_same_file 'tmp/cpr_src/b', 'tmp/cpr_dest/b'
|
assert_same_file 'tmp/cpr_src/b', 'tmp/cpr_dest/b'
|
||||||
assert_same_file 'tmp/cpr_src/c', 'tmp/cpr_dest/c'
|
assert_same_file 'tmp/cpr_src/c', 'tmp/cpr_dest/c'
|
||||||
assert_directory 'tmp/cpr_dest/d'
|
assert_directory 'tmp/cpr_dest/d'
|
||||||
rm_rf 'tmp/cpr_src'
|
my_rm_rf 'tmp/cpr_src'
|
||||||
rm_rf 'tmp/cpr_dest'
|
my_rm_rf 'tmp/cpr_dest'
|
||||||
|
|
||||||
if have_symlink?
|
if have_symlink?
|
||||||
# symlink in a directory
|
# symlink in a directory
|
||||||
|
@ -275,7 +283,8 @@ if have_symlink?
|
||||||
ln_s 'cpr_src', 'tmp/cpr_src2'
|
ln_s 'cpr_src', 'tmp/cpr_src2'
|
||||||
cp_r 'tmp/cpr_src2', 'tmp/cpr_dest2'
|
cp_r 'tmp/cpr_src2', 'tmp/cpr_dest2'
|
||||||
assert_directory 'tmp/cpr_dest2'
|
assert_directory 'tmp/cpr_dest2'
|
||||||
assert_not_symlink 'tmp/cpr_dest2'
|
#assert_not_symlink 'tmp/cpr_dest2'
|
||||||
|
assert_symlink 'tmp/cpr_dest2' # 2005-05-26: feature change
|
||||||
assert_symlink 'tmp/cpr_dest2/symlink'
|
assert_symlink 'tmp/cpr_dest2/symlink'
|
||||||
assert_equal 'SLdest', File.readlink('tmp/cpr_dest2/symlink')
|
assert_equal 'SLdest', File.readlink('tmp/cpr_dest2/symlink')
|
||||||
end
|
end
|
||||||
|
@ -633,14 +642,14 @@ end
|
||||||
tmpdir/a/a/a/a/a/a/a/a/a/a/a/a/a/a/a/a/a/a
|
tmpdir/a/a/a/a/a/a/a/a/a/a/a/a/a/a/a/a/a/a
|
||||||
tmpdir/a/a
|
tmpdir/a/a
|
||||||
)
|
)
|
||||||
rm_rf 'tmpdir'
|
my_rm_rf 'tmpdir'
|
||||||
dirs.each do |d|
|
dirs.each do |d|
|
||||||
mkdir_p d
|
mkdir_p d
|
||||||
assert_directory d
|
assert_directory d
|
||||||
assert_file_not_exist "#{d}/a"
|
assert_file_not_exist "#{d}/a"
|
||||||
assert_file_not_exist "#{d}/b"
|
assert_file_not_exist "#{d}/b"
|
||||||
assert_file_not_exist "#{d}/c"
|
assert_file_not_exist "#{d}/c"
|
||||||
rm_rf 'tmpdir'
|
my_rm_rf 'tmpdir'
|
||||||
end
|
end
|
||||||
dirs.each do |d|
|
dirs.each do |d|
|
||||||
mkdir_p d
|
mkdir_p d
|
||||||
|
@ -733,7 +742,7 @@ end
|
||||||
touch 'tmp/b'
|
touch 'tmp/b'
|
||||||
mkdir 'tmp/dest'
|
mkdir 'tmp/dest'
|
||||||
install [Pathname.new('tmp/a'), Pathname.new('tmp/b')], 'tmp/dest'
|
install [Pathname.new('tmp/a'), Pathname.new('tmp/b')], 'tmp/dest'
|
||||||
rm_rf 'tmp/dest'
|
my_rm_rf 'tmp/dest'
|
||||||
mkdir 'tmp/dest'
|
mkdir 'tmp/dest'
|
||||||
install [Pathname.new('tmp/a'), Pathname.new('tmp/b')], Pathname.new('tmp/dest')
|
install [Pathname.new('tmp/a'), Pathname.new('tmp/b')], Pathname.new('tmp/dest')
|
||||||
}
|
}
|
||||||
|
@ -783,7 +792,7 @@ end
|
||||||
end
|
end
|
||||||
|
|
||||||
# duck typing test [ruby-dev:25369]
|
# duck typing test [ruby-dev:25369]
|
||||||
rm_rf 'tmp'
|
my_rm_rf 'tmp'
|
||||||
Dir.mkdir 'tmp'
|
Dir.mkdir 'tmp'
|
||||||
each_srcdest do |srcpath, destpath|
|
each_srcdest do |srcpath, destpath|
|
||||||
File.open(srcpath) {|src|
|
File.open(srcpath) {|src|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue