commit 3ebc2c88
it turns out that a large part of my pileline does not support libphsyfs. Add backward compatibility
Changed files
| M | source/code/sago/SagoDataHolder.cpp before |
| M | source/code/sago/SagoMisc.cpp before |
diff --git a/source/code/sago/SagoDataHolder.cpp b/source/code/sago/SagoDataHolder.cpp
index 4818efa..abe3c4b 100644
--- a/source/code/sago/SagoDataHolder.cpp
+++ b/source/code/sago/SagoDataHolder.cpp
@@ -32,6 +32,11 @@ SOFTWARE.
#include <SDL_mixer.h>
#include "SagoMiscSdl2.hpp"
+#if PHYSFS_VER_MAJOR < 3
+#define PHYSFS_readBytes(X,Y,Z) PHYSFS_read(X,Y,1,Z)
+#define PHYSFS_writeBytes(X,Y,Z) PHYSFS_write(X,Y,1,Z)
+#endif
+
namespace sago {
struct SagoDataHolder::SagoDataHolderData {
diff --git a/source/code/sago/SagoMisc.cpp b/source/code/sago/SagoMisc.cpp
index 0ec9c0f..536234e 100644
--- a/source/code/sago/SagoMisc.cpp
+++ b/source/code/sago/SagoMisc.cpp
@@ -29,6 +29,11 @@ SOFTWARE.
#include <string.h>
#include <memory>
+#if PHYSFS_VER_MAJOR < 3
+#define PHYSFS_readBytes(X,Y,Z) PHYSFS_read(X,Y,1,Z)
+#define PHYSFS_writeBytes(X,Y,Z) PHYSFS_write(X,Y,1,Z)
+#endif
+
using std::string;
using std::cerr;
using std::vector;
@@ -85,8 +90,12 @@ void WriteFileContent(const char* filename, const std::string& content) {
CreatePathToFile(filename);
PHYSFS_file* myfile = PHYSFS_openWrite(filename);
if (!myfile) {
+#if PHYSFS_VER_MAJOR > 2
PHYSFS_ErrorCode code = PHYSFS_getLastErrorCode();
- cerr << "Failed to open file for writing, " << PHYSFS_getErrorByCode(code) << " (" << code << ")\n";
+ std::cerr << "Failed to open file for writing, " << PHYSFS_getErrorByCode(code) << " (" << code << ")\n";
+#else
+ std::cerr << "Failed to open file for writing, " << PHYSFS_getLastError() << "\n";
+#endif
return;
}
PHYSFS_writeBytes(myfile, content.c_str(), sizeof(char)*content.length());