1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
|
From 6e4e12826fd144c874c93c2efb669fbb119b831a Mon Sep 17 00:00:00 2001
From: Andreas Sturmlechner <asturm@gentoo.org>
Date: Tue, 30 Jan 2024 23:56:14 +0100
Subject: [PATCH] Import boost_string_file.hpp from boost-1.83 and put it to
use immediately
string_file.hpp was deprecated in boost-1.79.0 and removed in 1.84.0
Signed-off-by: Andreas Sturmlechner <asturm@gentoo.org>
---
common/boost_string_file.hpp | 59 ++++++++++++++++++++++++++++++++++
lang/LangSource/PyrLexer.cpp | 2 +-
server/scsynth/SC_GraphDef.cpp | 2 +-
3 files changed, 61 insertions(+), 2 deletions(-)
create mode 100644 common/boost_string_file.hpp
diff --git a/common/boost_string_file.hpp b/common/boost_string_file.hpp
new file mode 100644
index 000000000..1ccb63de6
--- /dev/null
+++ b/common/boost_string_file.hpp
@@ -0,0 +1,59 @@
+// filesystem/string_file.hpp --------------------------------------------------------//
+
+// Copyright Beman Dawes 2015
+
+// Distributed under the Boost Software License, Version 1.0.
+// See http://www.boost.org/LICENSE_1_0.txt
+
+// Library home page: http://www.boost.org/libs/filesystem
+
+#ifndef BOOST_FILESYSTEM_STRING_FILE_HPP
+#define BOOST_FILESYSTEM_STRING_FILE_HPP
+
+#include <boost/filesystem/config.hpp>
+
+#include <cstddef>
+#include <limits>
+#include <string>
+#include <ios>
+#include <stdexcept>
+#include <boost/cstdint.hpp>
+#include <boost/filesystem/path.hpp>
+#include <boost/filesystem/fstream.hpp>
+#include <boost/filesystem/operations.hpp>
+
+#include <boost/filesystem/detail/header.hpp> // must be the last #include
+
+namespace boost {
+namespace filesystem {
+
+inline void save_string_file(path const& p, std::string const& str)
+{
+ filesystem::ofstream file;
+ file.exceptions(std::ios_base::failbit | std::ios_base::badbit);
+ file.open(p, std::ios_base::binary);
+ const std::size_t sz = str.size();
+ if (BOOST_UNLIKELY(sz > static_cast< boost::uintmax_t >((std::numeric_limits< std::streamsize >::max)())))
+ BOOST_FILESYSTEM_THROW(std::length_error("String size exceeds max write size"));
+ file.write(str.c_str(), static_cast< std::streamsize >(sz));
+}
+
+inline void load_string_file(path const& p, std::string& str)
+{
+ filesystem::ifstream file;
+ file.exceptions(std::ios_base::failbit | std::ios_base::badbit);
+ file.open(p, std::ios_base::binary);
+ const boost::uintmax_t sz = filesystem::file_size(p);
+ if (BOOST_UNLIKELY(sz > static_cast< boost::uintmax_t >((std::numeric_limits< std::streamsize >::max)())))
+ BOOST_FILESYSTEM_THROW(std::length_error("File size exceeds max read size"));
+ str.resize(static_cast< std::size_t >(sz), '\0');
+ if (sz > 0u)
+ file.read(&str[0], static_cast< std::streamsize >(sz));
+}
+
+} // namespace filesystem
+} // namespace boost
+
+#include <boost/filesystem/detail/footer.hpp>
+
+#endif // BOOST_FILESYSTEM_STRING_FILE_HPP
diff --git a/lang/LangSource/PyrLexer.cpp b/lang/LangSource/PyrLexer.cpp
index 7ebe3d726..06c1454ca 100644
--- a/lang/LangSource/PyrLexer.cpp
+++ b/lang/LangSource/PyrLexer.cpp
@@ -38,7 +38,7 @@
#include <boost/filesystem/path.hpp>
#include <boost/filesystem/operations.hpp>
-#include <boost/filesystem/string_file.hpp>
+#include "boost_string_file.hpp"
#include "PyrParseNode.h"
#include "Bison/lang11d_tab.h"
diff --git a/server/scsynth/SC_GraphDef.cpp b/server/scsynth/SC_GraphDef.cpp
index 957aca193..5f8f15741 100644
--- a/server/scsynth/SC_GraphDef.cpp
+++ b/server/scsynth/SC_GraphDef.cpp
@@ -46,7 +46,7 @@
#include <string>
#include <boost/filesystem/operations.hpp> // recursive_directory_iterator
-#include <boost/filesystem/string_file.hpp> // load_string_file
+#include "boost_string_file.hpp" // load_string_file
namespace bfs = boost::filesystem;
--
2.43.0
|