| 2814 | } |
| 2815 | |
| 2816 | BOOST_FILESYSTEM_DECL |
| 2817 | void copy(path const& from, path const& to, copy_options options, system::error_code* ec) |
| 2818 | { |
| 2819 | BOOST_ASSERT((((options & copy_options::overwrite_existing) != copy_options::none) + |
| 2820 | ((options & copy_options::skip_existing) != copy_options::none) + |
| 2821 | ((options & copy_options::update_existing) != copy_options::none)) <= 1); |
| 2822 | |
| 2823 | BOOST_ASSERT((((options & copy_options::copy_symlinks) != copy_options::none) + |
| 2824 | ((options & copy_options::skip_symlinks) != copy_options::none)) <= 1); |
| 2825 | |
| 2826 | BOOST_ASSERT((((options & copy_options::directories_only) != copy_options::none) + |
| 2827 | ((options & copy_options::create_symlinks) != copy_options::none) + |
| 2828 | ((options & copy_options::create_hard_links) != copy_options::none)) <= 1); |
| 2829 | |
| 2830 | if (ec) |
| 2831 | ec->clear(); |
| 2832 | |
| 2833 | file_status from_stat; |
| 2834 | if ((options & (copy_options::copy_symlinks | copy_options::skip_symlinks | copy_options::create_symlinks)) != copy_options::none) |
| 2835 | { |
| 2836 | from_stat = detail::symlink_status_impl(from, ec); |
| 2837 | } |
| 2838 | else |
| 2839 | { |
| 2840 | from_stat = detail::status_impl(from, ec); |
| 2841 | } |
| 2842 | |
| 2843 | if (ec && *ec) |
| 2844 | return; |
| 2845 | |
| 2846 | if (!exists(from_stat)) |
| 2847 | { |
| 2848 | emit_error(BOOST_ERROR_FILE_NOT_FOUND, from, to, ec, "boost::filesystem::copy"); |
| 2849 | return; |
| 2850 | } |
| 2851 | |
| 2852 | if (is_symlink(from_stat)) |
| 2853 | { |
| 2854 | if ((options & copy_options::skip_symlinks) != copy_options::none) |
| 2855 | return; |
| 2856 | |
| 2857 | if ((options & copy_options::copy_symlinks) == copy_options::none) |
| 2858 | goto fail; |
| 2859 | |
| 2860 | detail::copy_symlink(from, to, ec); |
| 2861 | } |
| 2862 | else if (is_regular_file(from_stat)) |
| 2863 | { |
| 2864 | if ((options & copy_options::directories_only) != copy_options::none) |
| 2865 | return; |
| 2866 | |
| 2867 | if ((options & copy_options::create_symlinks) != copy_options::none) |
| 2868 | { |
| 2869 | const path* pfrom = &from; |
| 2870 | path relative_from; |
| 2871 | if (!from.is_absolute()) |
| 2872 | { |
| 2873 | // Try to generate a relative path from the target location to the original file |