MCPcopy Create free account
hub / github.com/boostorg/filesystem / copy

Function copy

src/operations.cpp:2816–3006  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

2814}
2815
2816BOOST_FILESYSTEM_DECL
2817void 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

Callers 9

test_copy_file_defaultFunction · 0.50
test_copy_dir_defaultFunction · 0.50
test_copy_dir_default_ecFunction · 0.50
test_copy_dir_recursiveFunction · 0.50
test_copy_file_symlinksFunction · 0.50
test_copy_errorsFunction · 0.50
mainFunction · 0.50
mainFunction · 0.50

Calls 15

symlink_status_implFunction · 0.85
status_implFunction · 0.85
emit_errorFunction · 0.85
absolute_v4Function · 0.85
clearMethod · 0.80
is_absoluteMethod · 0.80
parent_pathMethod · 0.80
typeMethod · 0.80
pathMethod · 0.80
copy_symlinkFunction · 0.70

Tested by 7

test_copy_file_defaultFunction · 0.40
test_copy_dir_defaultFunction · 0.40
test_copy_dir_default_ecFunction · 0.40
test_copy_dir_recursiveFunction · 0.40
test_copy_file_symlinksFunction · 0.40
test_copy_errorsFunction · 0.40