From 94aed6ece5517344760816e521ee5d62366dfafb Mon Sep 17 00:00:00 2001 From: "Satadru Pramanik, DO, MPH, MEng" Date: Thu, 9 Feb 2023 22:37:26 -0500 Subject: [ruby/fileutils] Add mkdir_p to FileUtils.install (https://github.com/ruby/fileutils/pull/104) * Add mkdir_p to FileUtils.install * Adjust raise message. * adjust raise language * handle trailing slash in dest * simplify * Add tests --- lib/fileutils.rb | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) (limited to 'lib/fileutils.rb') diff --git a/lib/fileutils.rb b/lib/fileutils.rb index b495078f93..7cbf9d8fa6 100644 --- a/lib/fileutils.rb +++ b/lib/fileutils.rb @@ -1642,7 +1642,13 @@ module FileUtils st = File.stat(s) unless File.exist?(d) and compare_file(s, d) remove_file d, true - copy_file s, d + if d.end_with?('/') + mkdir_p d + copy_file s, d + File.basename(s) + else + mkdir_p File.expand_path('..', d) + copy_file s, d + end File.utime st.atime, st.mtime, d if preserve File.chmod fu_mode(mode, st), d if mode File.chown uid, gid, d if uid or gid -- cgit v1.2.1