как выполнить повышение:: файловая система copy_file с перезаписью

PyCharm показывает вам список установленных пакетов с pip, а conda list показывает и pip, и conda. Между тем, вы можете переключаться между pip и conda с помощью специальной кнопки в PyCharm:

enter image description here

43
задан Ferruccio 13 July 2011 в 21:20
поделиться

3 ответа

Есть третий enum аргумент для copy_file, boost :: filesystem :: copy_option :: overwrite_if_exists

copy_file(source_path,destination_path,copy_option::overwrite_if_exists);
65
ответ дан 26 November 2019 в 22:45
поделиться

Test if the destination file exists first and if it does then remove it :

if (exists (to_fp))
    remove (to_fp);
copy_file (from_fp, to_fp);

Or if you're worried about the file appearing between the test and the copy then you could write to a temporary file and then rename it to the destination file.

9
ответ дан 26 November 2019 в 22:45
поделиться

Is there an elegant way to use the boost copy_file function and overwrite the target file?

Apparently there's no direct API to do this.

Or is it better to simply use the Windows API? My current target platform is Windows, but I prefer to use STL and boost where possible to keep my code platform independent.

From the documentation:

A proposal, N1975, to include Boost.Filesystem in Technical Report 2 has been accepted by the C++ Standards Committee. The Boost.Filesystem library will stay in alignment with the TR2 Filesystem proposal as it works its way through the TR2 process. Note, however, that namespaces and header granularity differs between Boost.Filesystem and the TR2 proposal.

Which strongly suggests that sticking with boost::filesystem is a good idea.

2
ответ дан 26 November 2019 в 22:45
поделиться
Другие вопросы по тегам:

Похожие вопросы: