Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Remove use of copy_file from boost.filesystem

copy_file's signature varies depending on whether or not boost was
compiled as C++11, which makes Linux packaging awkward.

Closes #1580. Closes #1581.
  • Loading branch information...
commit 2db687cc314c8558684517e594f4a39fc36c4308 1 parent 6e62f9e
@tgoyne tgoyne authored
View
7 aegisub/libaegisub/common/fs.cpp
@@ -23,7 +23,9 @@
#include "libaegisub/log.h"
#include <boost/algorithm/string/predicate.hpp>
+#define BOOST_NO_SCOPED_ENUMS
#include <boost/filesystem.hpp>
+#undef BOOST_NO_SCOPED_ENUMS
namespace bfs = boost::filesystem;
namespace ec = boost::system::errc;
@@ -94,11 +96,6 @@ namespace agi { namespace fs {
CHECKED_CALL(bfs::rename(from, to, ec), from, to);
}
- void Copy(path const& from, path const& to) {
- CreateDirectory(to.parent_path());
- CHECKED_CALL(bfs::copy_file(from, to, bfs::copy_option::overwrite_if_exists, ec), from, to);
- }
-
bool HasExtension(path const& p, std::string const& ext) {
auto filename = p.filename().string();
if (filename.size() < ext.size() + 1) return false;
View
3  aegisub/libaegisub/lagi_pre.h
@@ -61,6 +61,9 @@
// Boost
#include <boost/container/list.hpp>
#include <boost/container/map.hpp>
+#define BOOST_NO_SCOPED_ENUMS
+#include <boost/filesystem.hpp>
+#undef BOOST_NO_SCOPED_ENUMS
#ifdef __DEPRECATED // Dodge GCC warnings
# undef __DEPRECATED
View
11 aegisub/libaegisub/unix/fs.cpp
@@ -16,7 +16,9 @@
#include "config.h"
+#include "libaegisub/access.h"
#include "libaegisub/fs.h"
+#include "libaegisub/io.h"
#include <boost/filesystem.hpp>
#include <fcntl.h>
@@ -40,6 +42,15 @@ void Touch(path const& file) {
}
}
+void Copy(fs::path const& from, fs::path const& to) {
+ acs::CheckFileRead(from);
+ CreateDirectory(to.parent_path());
+ acs::CheckDirWrite(to.parent_path());
+
+ std::unique_ptr<std::istream> in(io::Open(from, true));
+ io::Save(to).Get() << in->rdbuf();
+}
+
struct DirectoryIterator::PrivData {
boost::system::error_code ec;
bfs::directory_iterator it;
View
17 aegisub/libaegisub/windows/fs.cpp
@@ -72,6 +72,23 @@ void Touch(path const& file) {
throw EnvironmentError("SetFileTime failed with error: " + util::ErrorString(GetLastError()));
}
+void Copy(fs::path const& from, fs::path const& to) {
+ acs::CheckFileRead(from);
+ CreateDirectory(to.parent_path());
+ acs::CheckDirWrite(to.parent_path());
+
+ if (!CopyFile(from.wstring().c_str(), to.wstring().c_str(), false)) {
+ switch (GetLastError()) {
+ case ERROR_FILE_NOT_FOUND:
+ throw FileNotFound(from);
+ case ERROR_ACCESS_DENIED:
+ throw fs::WriteDenied("Could not overwrite " + to.string());
+ default:
+ throw fs::WriteDenied("Could not copy: " + util::ErrorString(GetLastError()));
+ }
+ }
+}
+
struct DirectoryIterator::PrivData {
scoped_holder<HANDLE, BOOL (__stdcall *)(HANDLE)> h;
PrivData() : h(INVALID_HANDLE_VALUE, FindClose) { }

0 comments on commit 2db687c

Please sign in to comment.
Something went wrong with that request. Please try again.