summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRemko Tronçon <git@el-tramo.be>2010-03-28 15:46:49 (GMT)
committerRemko Tronçon <git@el-tramo.be>2010-03-28 15:46:49 (GMT)
commitf53a1ef582494458301b97bf6e546be52d7ff7e8 (patch)
tree7571b5cbcbd8a8f1dd1c966c9045b6cb69f0e295 /3rdParty/Boost/src/tools/bcp/copy_path.cpp
parent638345680d72ca6acaf123f2c8c1c391f696e371 (diff)
downloadswift-contrib-f53a1ef582494458301b97bf6e546be52d7ff7e8.zip
swift-contrib-f53a1ef582494458301b97bf6e546be52d7ff7e8.tar.bz2
Moving submodule contents back.
Diffstat (limited to '3rdParty/Boost/src/tools/bcp/copy_path.cpp')
-rw-r--r--3rdParty/Boost/src/tools/bcp/copy_path.cpp65
1 files changed, 65 insertions, 0 deletions
diff --git a/3rdParty/Boost/src/tools/bcp/copy_path.cpp b/3rdParty/Boost/src/tools/bcp/copy_path.cpp
new file mode 100644
index 0000000..c976865
--- /dev/null
+++ b/3rdParty/Boost/src/tools/bcp/copy_path.cpp
@@ -0,0 +1,65 @@
+/*
+ *
+ * Copyright (c) 2003 Dr John Maddock
+ * Use, modification and distribution is subject to the
+ * Boost Software License, Version 1.0. (See accompanying file
+ * LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
+ *
+ * This file implements the following:
+ * void bcp_implementation::copy_path(const fs::path& p)
+ * void bcp_implementation::create_path(const fs::path& p)
+ */
+
+#include "bcp_imp.hpp"
+#include <boost/filesystem/operations.hpp>
+#include <fstream>
+#include <iterator>
+#include <algorithm>
+#include <iostream>
+
+void bcp_implementation::copy_path(const fs::path& p)
+{
+ assert(!fs::is_directory(m_boost_path / p));
+ if(fs::exists(m_dest_path / p))
+ {
+ std::cout << "Copying (and overwriting) file: " << p.string() << "\n";
+ fs::remove(m_dest_path / p);
+ }
+ else
+ std::cout << "Copying file: " << p.string() << "\n";
+ //
+ // create the path to the new file if it doesn't already exist:
+ //
+ create_path(p.branch_path());
+ //
+ // do text based copy if requested:
+ //
+ if(m_unix_lines && !is_binary_file(p))
+ {
+ std::ifstream is((m_boost_path / p).native_file_string().c_str());
+ std::istreambuf_iterator<char> isi(is);
+ std::istreambuf_iterator<char> end;
+
+ std::ofstream os((m_dest_path / p).native_file_string().c_str(), std::ios_base::binary | std::ios_base::out);
+ std::ostreambuf_iterator<char> osi(os);
+
+ std::copy(isi, end, osi);
+ }
+ else
+ {
+ // binary copy:
+ fs::copy_file(m_boost_path / p, m_dest_path / p);
+ }
+}
+
+void bcp_implementation::create_path(const fs::path& p)
+{
+ if(!fs::exists(m_dest_path / p))
+ {
+ // recurse then create the path:
+ create_path(p.branch_path());
+ fs::create_directory(m_dest_path / p);
+ }
+}
+
+