Modifications to os::copy_file()

cc #9947