Но когда я подключил свой телефон через USB и активировал режим передачи файлов, то копирование в другое место на подключенном диске телефона не удалось выполнить с помощью функции std::filesystem::copy, которая, очевидно, является основной частью копирования в коде. Файл фактически создан, но содержимое не заполнено, поэтому он остается пустым, показывая ноль байтов для его размера.
Если я хочу переместить файл, используя функцию std::filesystem: :rename, тогда файл просто теряется - ничего не создается.
Код: Выделить всё
void actual_copy_or_move(
const std::filesystem::path& current_path,
const std::filesystem::path& target_path)
{
std::error_code err_code {};
if (m_do_move)
{
// Moving the file.
std::filesystem::rename(current_path, target_path, err_code);
}
else
{
// Straightforward copy, without any extra checks.
auto copy_lambda {[¤t_path, &target_path]() {
std::ifstream input_stream {current_path, std::ios::binary};
std::ofstream output_stream {target_path, std::ios::binary};
if (!input_stream.good() || !output_stream.good()) {
std::wcerr
Подробнее здесь: [url]https://stackoverflow.com/questions/79334254/why-stdfilesystemcopy-doesnt-copy-a-file-but-raw-copying-does-for-mounted[/url]