I rename the file using boost :: filesystem and sometimes the target file will exist. According to the acceleration instructions:
http://www.boost.org/doc/libs/1_42_0/libs/filesystem/doc/reference.html#Non-member-functions
void rename template (const Path1 & from_p, const Path2 & Up); Required: Path1 :: external_string_type and Path2 :: external_string_type are the same type.Effects: renames from_p to to_p, as if using POSIX rename ().Postconditions :! exists (from_p) && & exists (to_p), and the contents and attributes of the file are initially Named from_p otherwise do not change.[Note: if from_p and to_p allow the same file, no action is taken. Otherwise , if to_p resolves an existing file, it is deleted . the symlink itself is renamed, not the file that it allows is renamed. - final note]
void rename template (const Path1 & from_p, const Path2 & Up); Required: Path1 :: external_string_type and Path2 :: external_string_type are the same type.
Effects: renames from_p to to_p, as if using POSIX rename ().
Postconditions :! exists (from_p) && & exists (to_p), and the contents and attributes of the file are initially Named from_p otherwise do not change.
[Note: if from_p and to_p allow the same file, no action is taken. Otherwise , if to_p resolves an existing file, it is deleted . the symlink itself is renamed, not the file that it allows is renamed. - final note]
(my emphasis)
When testing this code compiled through MS Visual Studio 2008 on XP SP3, renaming causes boost :: filesystem :: filesystem_error with the message:
Unable to create file if this file already exists
I note that this was raised in the bug report: https://svn.boost.org/trac/boost/ticket/2866
... but claims to be closed in Boost 1.41.0, and I'm using Boost 1.42.0.
Am I doing something wrong here or do I just need to go back to std :: rename?
Linux, , .
, , Boost.Filesystem "V3", Boost .
Boost 1.43.0 Linux - , POSIX . , , MoveFile Windows ? V3 MoveFileEx Windows std::rename POSIX .
MoveFile
MoveFileEx
std::rename
, , boost::filesystem::remove boost::filesystem::rename, , .
boost::filesystem::remove
boost::filesystem::rename
Source: https://habr.com/ru/post/1752604/More articles:Как подавить вывод кавычек как HTML-сущности? - htmlRuby Date Extension - datehttps://translate.googleusercontent.com/translate_c?depth=1&pto=aue&rurl=translate.google.com&sl=ru&sp=nmt4&tl=en&u=https://fooobar.com/questions/1752601/is-there-a-way-for-emacs-to-autocorrect-r-commands&usg=ALkJrhgTFuzEZwEoArKMtdRcemuZ6u-gkQJQuery Link Caching - jqueryJBoss EJB2 Timer Service - Multiple Servers, One TIMERS Table? - javaЕдиничное тестирование с помощью Spring рамки singleton beans - javajQuery next (ish) selector - jquerycannot find type "bigint" in Sybase ASE 12.5.4 - sqldatatypeshow to send data from android to server - androiddoubts about client-side validation - javaAll Articles