Copy a file in a sane, safe and efficient way

前端 未结 7 1373
小蘑菇
小蘑菇 2020-11-22 07:11

I search for a good way to copy a file (binary or text). I\'ve written several samples, everyone works. But I want hear the opinion of seasoned programmers.

I missin

相关标签:
7条回答
  • 2020-11-22 07:42

    With C++17 the standard way to copy a file will be including the <filesystem> header and using:

    bool copy_file( const std::filesystem::path& from,
                    const std::filesystem::path& to);
    
    bool copy_file( const std::filesystem::path& from,
                    const std::filesystem::path& to,
                    std::filesystem::copy_options options);
    

    The first form is equivalent to the second one with copy_options::none used as options (see also copy_file).

    The filesystem library was originally developed as boost.filesystem and finally merged to ISO C++ as of C++17.

    0 讨论(0)
提交回复
热议问题