summaryrefslogtreecommitdiff
path: root/rlvm/boost_filesystem_v3.patch
blob: 4f0ce7bf2047f54436d94105f78c2894e921ffd8 (plain)
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
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
diff --git a/SConstruct b/SConstruct
index 6fceb57..08be1ad 100644
--- a/SConstruct
+++ b/SConstruct
@@ -45,10 +45,6 @@ env = Environment(
   CPPDEFINES = [
     "HAVE_CONFIG_H",
 
-    # boost made a large non-backwards compatible change to their filesystem
-    # library. Specify version 2 explicitly.
-    ["BOOST_FILESYSTEM_VERSION", 2],
-
     # We use gettext for translations.
     "ENABLE_NLS",
 
diff --git a/src/MachineBase/RLVMInstance.cpp b/src/MachineBase/RLVMInstance.cpp
index 2cba1aa..4dc4215 100644
--- a/src/MachineBase/RLVMInstance.cpp
+++ b/src/MachineBase/RLVMInstance.cpp
@@ -71,9 +71,6 @@ RLVMInstance::RLVMInstance()
       count_undefined_copcodes_(false),
       load_save_(-1) {
   srand(time(NULL));
-
-  // Set global state: allow spaces in game paths
-  fs::path::default_name_check(fs::native);
 }
 
 RLVMInstance::~RLVMInstance() {}
@@ -88,7 +85,7 @@ void RLVMInstance::Run(const boost::filesystem::path& gamerootPath) {
     CheckBadEngine(gamerootPath, siglus_exes, _("Can't run Siglus games"));
 
     Gameexe gameexe(gameexePath);
-    gameexe("__GAMEPATH") = gamerootPath.file_string();
+    gameexe("__GAMEPATH") = gamerootPath.string();
 
     // Possibly force starting at a different seen
     if (seen_start_ != -1)
@@ -109,7 +106,7 @@ void RLVMInstance::Run(const boost::filesystem::path& gamerootPath) {
     }
 
     SDLSystem sdlSystem(gameexe);
-    libReallive::Archive arc(seenPath.file_string(), gameexe("REGNAME"));
+    libReallive::Archive arc(seenPath.string(), gameexe("REGNAME"));
     RLMachine rlmachine(sdlSystem, arc);
     addAllModules(rlmachine);
     addGameHacks(rlmachine);
diff --git a/src/MachineBase/SerializationGlobal.cpp b/src/MachineBase/SerializationGlobal.cpp
index c06d7d3..17230b4 100644
--- a/src/MachineBase/SerializationGlobal.cpp
+++ b/src/MachineBase/SerializationGlobal.cpp
@@ -36,6 +36,7 @@
 #include <boost/serialization/map.hpp>
 #include <boost/filesystem/path.hpp>
 #include <boost/filesystem/fstream.hpp>
+#include <boost/filesystem/operations.hpp>
 #include <boost/iostreams/filtering_stream.hpp>
 #include <boost/iostreams/filter/zlib.hpp>
 #include <fstream>
@@ -117,8 +118,8 @@ void loadGlobalMemory(RLMachine& machine) {
       // data is corrupted. Either way, we can't safely do ANYTHING with this
       // game's entire save data so move it out of the way.
       fs::path save_dir = machine.system().gameSaveDirectory();
-      fs::path dest_save_dir = save_dir.branch_path() /
-                               (save_dir.leaf() + ".old_corrupted_data");
+      fs::path dest_save_dir = save_dir.parent_path() /
+                               (save_dir.filename() / ".old_corrupted_data");
 
       if (fs::exists(dest_save_dir))
         fs::remove_all(dest_save_dir);
diff --git a/src/Modules/Module_Sys_Save.cpp b/src/Modules/Module_Sys_Save.cpp
index 02284ea..09cf443 100644
--- a/src/Modules/Module_Sys_Save.cpp
+++ b/src/Modules/Module_Sys_Save.cpp
@@ -255,7 +255,7 @@ struct LatestSave : public RLOp_Store_Void {
     if (fs::exists(saveDir)) {
       fs::directory_iterator end;
       for (fs::directory_iterator it(saveDir); it != end; ++it) {
-        string filename = it->leaf();
+        string filename = it->path().filename().string();
         if (starts_with(filename, "save") && ends_with(filename, ".sav.gz")) {
           time_t mtime = fs::last_write_time(*it);
 
diff --git a/src/Systems/Base/GraphicsSystem.cpp b/src/Systems/Base/GraphicsSystem.cpp
index 592216a..a983649 100644
--- a/src/Systems/Base/GraphicsSystem.cpp
+++ b/src/Systems/Base/GraphicsSystem.cpp
@@ -766,7 +766,7 @@ GraphicsObjectData* GraphicsSystem::buildObjOfFile(
     throw rlvm::Exception(oss.str());
   }
 
-  string file_str = full_path.file_string();
+  string file_str = full_path.string();
   if (iends_with(file_str, "g00") || iends_with(file_str, "pdt")) {
     return new GraphicsObjectOfFile(system(), filename);
   } else if (iends_with(file_str, "anm")) {
diff --git a/src/Systems/Base/KOEPACVoiceArchive.cpp b/src/Systems/Base/KOEPACVoiceArchive.cpp
index 5a53389..ec712a1 100644
--- a/src/Systems/Base/KOEPACVoiceArchive.cpp
+++ b/src/Systems/Base/KOEPACVoiceArchive.cpp
@@ -167,7 +167,7 @@ int8_t koe_ad_trans_tbl[256] = {
 class KOEPACVoiceSample : public VoiceSample {
  public:
   KOEPACVoiceSample(fs::path file, int offset, int length, int rate)
-      : stream_(std::fopen(file.external_file_string().c_str(), "rb")),
+      : stream_(std::fopen(file.native().c_str(), "rb")),
         offset_(offset), length_(length), rate_(rate) {
   }
 
diff --git a/src/Systems/Base/NWKVoiceArchive.cpp b/src/Systems/Base/NWKVoiceArchive.cpp
index e5abccf..f215b18 100644
--- a/src/Systems/Base/NWKVoiceArchive.cpp
+++ b/src/Systems/Base/NWKVoiceArchive.cpp
@@ -55,7 +55,7 @@ class NWKVoiceSample : public VoiceSample {
 NWKVoiceSample::NWKVoiceSample(boost::filesystem::path file,
                                int offset,
                                int length)
-    : stream_(std::fopen(file.external_file_string().c_str(), "rb")),
+    : stream_(std::fopen(file.native().c_str(), "rb")),
       offset_(offset), length_(length) {
 }
 
diff --git a/src/Systems/Base/OVKVoiceSample.cpp b/src/Systems/Base/OVKVoiceSample.cpp
index 0318356..efef262 100644
--- a/src/Systems/Base/OVKVoiceSample.cpp
+++ b/src/Systems/Base/OVKVoiceSample.cpp
@@ -113,7 +113,7 @@ std::string oggErrorCodeToString(int code) {
 }  // namespace
 
 OVKVoiceSample::OVKVoiceSample(fs::path file)
-    : stream_(std::fopen(file.external_file_string().c_str(), "rb")),
+    : stream_(std::fopen(file.native().c_str(), "rb")),
       offset_(0), length_(0) {
   std::fseek(stream_, 0, SEEK_END);
   length_ = ftell(stream_);
@@ -121,7 +121,7 @@ OVKVoiceSample::OVKVoiceSample(fs::path file)
 }
 
 OVKVoiceSample::OVKVoiceSample(fs::path file, int offset, int length)
-    : stream_(std::fopen(file.external_file_string().c_str(), "rb")),
+    : stream_(std::fopen(file.native().c_str(), "rb")),
       offset_(offset), length_(length) {
 }
 
diff --git a/src/Systems/Base/System.cpp b/src/Systems/Base/System.cpp
index aa5990d..636a007 100644
--- a/src/Systems/Base/System.cpp
+++ b/src/Systems/Base/System.cpp
@@ -466,7 +466,7 @@ void System::buildFileSystemCache() {
   fs::directory_iterator dir_end;
   for (fs::directory_iterator dir(gamepath); dir != dir_end; ++dir) {
     if (fs::is_directory(dir->status())) {
-      std::string lowername = dir->path().filename();
+      std::string lowername = dir->path().filename().string();
       to_lower(lowername);
       if (find(valid_directories.begin(), valid_directories.end(), lowername) !=
           valid_directories.end()) {
@@ -482,14 +482,14 @@ void System::addDirectoryToCache(const fs::path& directory) {
     if (fs::is_directory(dir->status())) {
       addDirectoryToCache(dir->path());
     } else {
-      std::string extension = dir->path().extension();
+      std::string extension = dir->path().extension().string();
       if (extension.size() > 1 && extension[0] == '.')
         extension = extension.substr(1);
       to_lower(extension);
 
       if (find(ALL_FILETYPES.begin(), ALL_FILETYPES.end(), extension) !=
           ALL_FILETYPES.end()) {
-        std::string stem = dir->path().stem();
+        std::string stem = dir->path().stem().string();
         to_lower(stem);
 
         filesystem_cache_.insert(
diff --git a/src/Systems/Base/VoiceCache.cpp b/src/Systems/Base/VoiceCache.cpp
index ad30131..d1b6371 100644
--- a/src/Systems/Base/VoiceCache.cpp
+++ b/src/Systems/Base/VoiceCache.cpp
@@ -93,7 +93,7 @@ shared_ptr<VoiceArchive> VoiceCache::findArchive(int file_no) const {
     return shared_ptr<VoiceArchive>();
   }
 
-  string file_str = file.file_string();
+  string file_str = file.string();
   if (iends_with(file_str, "ovk")) {
     return shared_ptr<VoiceArchive>(new OVKVoiceArchive(file, file_no));
   } else if (iends_with(file_str, "nwk")) {
@@ -116,7 +116,7 @@ shared_ptr<VoiceSample> VoiceCache::findUnpackedSample(
 
   fs::path file =
       sound_system_.system().findFile(oss.str(), KOE_LOOSE_FILETYPES);
-  string file_str = file.file_string();
+  string file_str = file.string();
 
   if (iends_with(file_str, "ogg")) {
     return shared_ptr<VoiceSample>(new OVKVoiceSample(file));
diff --git a/src/Systems/SDL/SDLGraphicsSystem.cpp b/src/Systems/SDL/SDLGraphicsSystem.cpp
index 4b444c8..0c07e2c 100644
--- a/src/Systems/SDL/SDLGraphicsSystem.cpp
+++ b/src/Systems/SDL/SDLGraphicsSystem.cpp
@@ -572,7 +572,7 @@ boost::shared_ptr<const Surface> SDLGraphicsSystem::loadNonCGSurfaceFromFile(
   }
 
   // Glue code to allow my stuff to work with Jagarl's loader
-  FILE* file = fopen(filename.file_string().c_str(), "rb");
+  FILE* file = fopen(filename.string().c_str(), "rb");
   if (!file) {
     ostringstream oss;
     oss << "Could not open file: " << filename;
diff --git a/src/Systems/SDL/SDLMusic.cpp b/src/Systems/SDL/SDLMusic.cpp
index ebcb611..7d32a96 100644
--- a/src/Systems/SDL/SDLMusic.cpp
+++ b/src/Systems/SDL/SDLMusic.cpp
@@ -205,7 +205,7 @@ boost::shared_ptr<SDLMusic> SDLMusic::CreateMusic(
     throw rlvm::Exception(oss.str());
   }
 
-  const string& raw_path = file_path.external_file_string();
+  const string& raw_path = file_path.native();
   for (FileTypes::const_iterator it = types.begin(); it != types.end(); ++it) {
     if (iends_with(raw_path, it->first)) {
       FILE* f = fopen(raw_path.c_str(), "r");
diff --git a/src/Systems/SDL/SDLSoundChunk.cpp b/src/Systems/SDL/SDLSoundChunk.cpp
index 99c5ac7..ee57b51 100644
--- a/src/Systems/SDL/SDLSoundChunk.cpp
+++ b/src/Systems/SDL/SDLSoundChunk.cpp
@@ -51,11 +51,11 @@ SDLSoundChunk::~SDLSoundChunk() {
 }
 
 Mix_Chunk* SDLSoundChunk::loadSample(const boost::filesystem::path& path) {
-  if (boost::iequals(path.extension(), ".nwa")) {
+  if (boost::iequals(path.extension().string(), ".nwa")) {
     // Hack to load NWA sounds into a MixChunk. I was resisted doing this
     // because I assumed there was a better way, but this is essentially what
     // jagarl does in xclannad too :(
-    FILE* f = fopen(path.external_file_string().c_str(), "r");
+    FILE* f = fopen(path.native().c_str(), "r");
     if (!f)
       return NULL;
     int size = 0;
@@ -67,7 +67,7 @@ Mix_Chunk* SDLSoundChunk::loadSample(const boost::filesystem::path& path) {
 
     return chunk;
   } else {
-    return Mix_LoadWAV(path.external_file_string().c_str());
+    return Mix_LoadWAV(path.native().c_str());
   }
 }
 
diff --git a/src/Systems/SDL/SDLTextSystem.cpp b/src/Systems/SDL/SDLTextSystem.cpp
index 07cea54..1c64049 100644
--- a/src/Systems/SDL/SDLTextSystem.cpp
+++ b/src/Systems/SDL/SDLTextSystem.cpp
@@ -139,7 +139,7 @@ int SDLTextSystem::charWidth(int size, uint16_t codepoint) {
 boost::shared_ptr<TTF_Font> SDLTextSystem::getFontOfSize(int size) {
   FontSizeMap::iterator it = map_.find(size);
   if (it == map_.end()) {
-    string filename = findFontFile(system()).external_file_string();
+    string filename = findFontFile(system()).native();
     TTF_Font* f = TTF_OpenFont(filename.c_str(), size);
     if (f == NULL) {
       ostringstream oss;
diff --git a/src/Utilities/File.cpp b/src/Utilities/File.cpp
index 2db0e2e..8d1c5de 100644
--- a/src/Utilities/File.cpp
+++ b/src/Utilities/File.cpp
@@ -72,7 +72,7 @@ fs::path correctPathCase(fs::path Path) {
   // which may have incorrect case.
   stack<string> pathElts;
   while (!Path.empty() && !exists(Path)) {
-    pathElts.push(Path.leaf());
+    pathElts.push(Path.filename().string());
     Path = Path.branch_path();
   }
   // Now proceed forwards through the possibly-incorrect elements.
@@ -96,10 +96,10 @@ fs::path correctPathCase(fs::path Path) {
       directory_iterator end;
       bool found = false;
       for (directory_iterator dir(Path); dir != end; ++dir) {
-        string uleaf = dir->leaf();
+        string uleaf = dir->path().filename().string();
         to_upper(uleaf);
         if (uleaf == elt && (!needDir || is_directory(*dir))) {
-          Path /= dir->leaf();
+          Path /= dir->path().filename();
           found = true;
           break;
         }
diff --git a/src/libReallive/archive.cpp b/src/libReallive/archive.cpp
index fbde57b..f36e222 100644
--- a/src/libReallive/archive.cpp
+++ b/src/libReallive/archive.cpp
@@ -100,7 +100,7 @@ void Archive::readOverrides() {
   fs::path seen_dir = fs::path(name).branch_path();
   fs::directory_iterator end;
   for (fs::directory_iterator it(seen_dir); it != end; ++it) {
-    string filename = it->leaf();
+    string filename = it->path().filename().string();
     if (filename.size() == 12 &&
         istarts_with(filename, "seen") &&
         iends_with(filename, ".txt") &&
diff --git a/vendor/wxInclude.cpp b/vendor/wxInclude.cpp
index 7d4e6c5..0203f55 100644
--- a/vendor/wxInclude.cpp
+++ b/vendor/wxInclude.cpp
@@ -266,7 +266,7 @@ int main(int argc, char* argv[]) {
 							std::cout << "Process: file '" << file << "'..." << std::endl;
 
 							/* Remove extension */
-                            file = inputpath.leaf();
+                            file = inputpath.filename().string();
 							boost::erase_last( file, fileext );
 
 							if ( !opt.count( "respectcase" ) )
@@ -316,7 +316,7 @@ int main(int argc, char* argv[]) {
 									fs::ifstream input( dir_itr->path(), std::ios::in | std::ios::binary | std::ios::ate );
 									input.rdbuf()->pubsetbuf( inbuffer, BUFFER_SIZE ); 
 
-									std::string file( dir_itr->path().leaf() );
+									std::string file( dir_itr->path().filename().string() );
 
 									if ( input.is_open() ) {
 										/* Show status */