From 0aaa65e768e6b12e2366543a167a002a40bbff63 Mon Sep 17 00:00:00 2001
From: Beman Dawes
Date: Sun, 17 May 2009 15:55:46 +0000
Subject: [PATCH] Fix Filesystem #2925, copy_file atomiticity
[SVN r53073]
---
doc/reference.html | 17 +++++++++---
include/boost/filesystem/operations.hpp | 14 +++++++---
src/operations.cpp | 36 +++++++++++++++----------
test/operations_test.cpp | 16 +++++++++++
4 files changed, 61 insertions(+), 22 deletions(-)
diff --git a/doc/reference.html b/doc/reference.html
index 05ce462..3916c08 100644
--- a/doc/reference.html
+++ b/doc/reference.html
@@ -410,8 +410,15 @@ error_code with the value of ec.
template <class Path> bool remove(const Path& p);
template <class Path1, class Path2>
void rename(const Path1& from_p, const Path2& to_p);
+
+ BOOST_SCOPED_ENUM_START(copy_option)
+ { fail_if_exists, overwrite_if_exists };
+ BOOST_SCOPED_ENUM_END
+
template <class Path1, class Path2>
- void copy_file(const Path1& from_fp, const Path2& to_fp);
+ void copy_file(const Path1& from_fp, const Path2& to_fp,
+ BOOST_SCOPED_ENUM(copy_option) option=copy_option::fail_if_exists);
+
template <class Path> Path system_complete(const Path& p);
template <class Path> Path complete(const Path& p, const Path& base=initial_path<Path>());
@@ -2249,7 +2256,9 @@ systems. --end note.]
existing file, it is removed. A symbolic link is itself renamed, rather than
the file it resolves to being renamed. -- end note]
-template <class Path1, class Path2> void copy_file(const Path1& from_fp, const Path2& to_fp);
+template <class Path1, class Path2>
+ void copy_file(const Path1& from_fp, const Path2& to_fp,
+ BOOST_SCOPED_ENUM(copy_option) option=copy_option::fail_if_exists);
Requires: Path1::external_string_type and
Path2::external_string_type are the same type.
@@ -2257,7 +2266,7 @@ systems. --end note.]
resolves to are copied to the file to_fp resolves to.
Throws: basic_filesystem_error<Path> if
from_fp.empty() || to_fp.empty() ||!exists(from_fp) || !is_regular_file(from_fp)
- || exists(to_fp)
+ || (option==copy_option::fail_if_exists && exists(to_fp))
template <class Path> Path complete(const Path& p, const Path& base=initial_path<Path>());
@@ -3076,7 +3085,7 @@ final document.
Distributed under the Boost Software License, Version 1.0. See
www.boost.org/LICENSE_1_0.txt
Revised
-13 October 2008
+17 May 2009