From c710f6a4ea2231051a9e6406128d6e06af86e58e Mon Sep 17 00:00:00 2001 From: Mat Date: Thu, 7 May 2020 22:14:00 +0300 Subject: Remove old Android leftovers (#4722) --- Tools/AnvilStats/Globals.h | 6 ------ Tools/GrownBiomeGenVisualiser/Globals.h | 10 ---------- Tools/MCADefrag/Globals.h | 10 ---------- Tools/NoiseSpeedTest/Globals.h | 10 ---------- Tools/ProtoProxy/Globals.h | 10 ---------- Tools/QtBiomeVisualiser/Globals.h | 6 ------ Tools/RCONClient/Globals.h | 10 ---------- src/Bindings/PluginLua.cpp | 6 +++--- src/Bindings/PluginManager.h | 2 +- src/Entities/Player.cpp | 4 ++-- src/FurnaceRecipe.cpp | 2 +- src/Globals.h | 6 ------ src/IniFile.cpp | 8 ++++---- src/LoggerListeners.cpp | 4 ++-- src/OSSupport/File.cpp | 8 ++++---- src/Server.cpp | 2 +- src/WebAdmin.cpp | 10 +++++----- src/World.cpp | 2 +- src/WorldStorage/MapSerializer.cpp | 12 ++++++------ src/WorldStorage/ScoreboardSerializer.cpp | 6 +++--- src/WorldStorage/StatSerializer.cpp | 8 ++++---- src/WorldStorage/WSSAnvil.cpp | 6 +++--- 22 files changed, 40 insertions(+), 108 deletions(-) diff --git a/Tools/AnvilStats/Globals.h b/Tools/AnvilStats/Globals.h index 4a8b0d433..bcf5bb159 100644 --- a/Tools/AnvilStats/Globals.h +++ b/Tools/AnvilStats/Globals.h @@ -148,12 +148,6 @@ typedef unsigned short UInt16; -#define FILE_IO_PREFIX "" - - - - - // CRT stuff: #include #include diff --git a/Tools/GrownBiomeGenVisualiser/Globals.h b/Tools/GrownBiomeGenVisualiser/Globals.h index f2d0149ba..33c983bf3 100644 --- a/Tools/GrownBiomeGenVisualiser/Globals.h +++ b/Tools/GrownBiomeGenVisualiser/Globals.h @@ -149,16 +149,6 @@ typedef unsigned char Byte; #define SocketError errno #endif -#if !defined(ANDROID_NDK) - #define USE_SQUIRREL -#endif - -#if defined(ANDROID_NDK) - #define FILE_IO_PREFIX "/sdcard/mcserver/" -#else - #define FILE_IO_PREFIX "" -#endif - diff --git a/Tools/MCADefrag/Globals.h b/Tools/MCADefrag/Globals.h index 058318de8..f0e535888 100644 --- a/Tools/MCADefrag/Globals.h +++ b/Tools/MCADefrag/Globals.h @@ -133,16 +133,6 @@ typedef unsigned char Byte; #define SocketError errno #endif -#if !defined(ANDROID_NDK) - #define USE_SQUIRREL -#endif - -#if defined(ANDROID_NDK) - #define FILE_IO_PREFIX "/sdcard/mcserver/" -#else - #define FILE_IO_PREFIX "" -#endif - diff --git a/Tools/NoiseSpeedTest/Globals.h b/Tools/NoiseSpeedTest/Globals.h index eb81d3552..22f39575e 100644 --- a/Tools/NoiseSpeedTest/Globals.h +++ b/Tools/NoiseSpeedTest/Globals.h @@ -141,16 +141,6 @@ typedef unsigned char Byte; #define SocketError errno #endif -#if !defined(ANDROID_NDK) - #define USE_SQUIRREL -#endif - -#if defined(ANDROID_NDK) - #define FILE_IO_PREFIX "/sdcard/mcserver/" -#else - #define FILE_IO_PREFIX "" -#endif - diff --git a/Tools/ProtoProxy/Globals.h b/Tools/ProtoProxy/Globals.h index 11e1fb7db..affd4b3fa 100644 --- a/Tools/ProtoProxy/Globals.h +++ b/Tools/ProtoProxy/Globals.h @@ -136,16 +136,6 @@ typedef unsigned char Byte; #define SocketError errno #endif -#if !defined(ANDROID_NDK) - #define USE_SQUIRREL -#endif - -#if defined(ANDROID_NDK) - #define FILE_IO_PREFIX "/sdcard/mcserver/" -#else - #define FILE_IO_PREFIX "" -#endif - diff --git a/Tools/QtBiomeVisualiser/Globals.h b/Tools/QtBiomeVisualiser/Globals.h index 0fed2cd48..97b44dda0 100644 --- a/Tools/QtBiomeVisualiser/Globals.h +++ b/Tools/QtBiomeVisualiser/Globals.h @@ -209,12 +209,6 @@ template class SizeChecker; #include #endif -#if defined(ANDROID_NDK) - #define FILE_IO_PREFIX "/sdcard/mcserver/" -#else - #define FILE_IO_PREFIX "" -#endif - diff --git a/Tools/RCONClient/Globals.h b/Tools/RCONClient/Globals.h index e025377dd..f8558b032 100644 --- a/Tools/RCONClient/Globals.h +++ b/Tools/RCONClient/Globals.h @@ -166,16 +166,6 @@ typedef unsigned char Byte; #include #endif -#if !defined(ANDROID_NDK) - #define USE_SQUIRREL -#endif - -#if defined(ANDROID_NDK) - #define FILE_IO_PREFIX "/sdcard/mcserver/" -#else - #define FILE_IO_PREFIX "" -#endif - diff --git a/src/Bindings/PluginLua.cpp b/src/Bindings/PluginLua.cpp index fac07f00b..13e2084ca 100644 --- a/src/Bindings/PluginLua.cpp +++ b/src/Bindings/PluginLua.cpp @@ -94,18 +94,18 @@ bool cPluginLua::Load(void) lua_setglobal(m_LuaState, LUA_PLUGIN_NAME_VAR_NAME); // Add the plugin's folder to the package.path and package.cpath variables (#693): - m_LuaState.AddPackagePath("path", FILE_IO_PREFIX + GetLocalFolder() + "/?.lua"); + m_LuaState.AddPackagePath("path", GetLocalFolder() + "/?.lua"); #ifdef _WIN32 m_LuaState.AddPackagePath("cpath", GetLocalFolder() + "\\?.dll"); #else - m_LuaState.AddPackagePath("cpath", FILE_IO_PREFIX + GetLocalFolder() + "/?.so"); + m_LuaState.AddPackagePath("cpath", GetLocalFolder() + "/?.so"); #endif tolua_pushusertype(m_LuaState, this, "cPluginLua"); lua_setglobal(m_LuaState, "g_Plugin"); } - std::string PluginPath = FILE_IO_PREFIX + GetLocalFolder() + "/"; + std::string PluginPath = GetLocalFolder() + "/"; // List all Lua files for this plugin. Info.lua has a special handling - make it the last to load: AStringVector Files = cFile::GetFolderContents(PluginPath.c_str()); diff --git a/src/Bindings/PluginManager.h b/src/Bindings/PluginManager.h index 79b7511ea..3b35a826a 100644 --- a/src/Bindings/PluginManager.h +++ b/src/Bindings/PluginManager.h @@ -387,7 +387,7 @@ public: /** Returns the path where individual plugins' folders are expected. The path doesn't end in a slash. */ - static AString GetPluginsPath(void) { return FILE_IO_PREFIX "Plugins"; } // tolua_export + static AString GetPluginsPath(void) { return "Plugins"; } // tolua_export private: friend class cRoot; diff --git a/src/Entities/Player.cpp b/src/Entities/Player.cpp index 3f2ab21c1..f82b23e6b 100644 --- a/src/Entities/Player.cpp +++ b/src/Entities/Player.cpp @@ -62,7 +62,7 @@ AString GetUUIDFolderName(const cUUID & a_Uuid) { AString UUID = a_Uuid.ToShortString(); - AString res(FILE_IO_PREFIX "players/"); + AString res("players/"); res.append(UUID, 0, 2); res.push_back('/'); return res; @@ -2946,7 +2946,7 @@ AString cPlayer::GetUUIDFileName(const cUUID & a_UUID) { AString UUID = a_UUID.ToLongString(); - AString res(FILE_IO_PREFIX "players/"); + AString res("players/"); res.append(UUID, 0, 2); res.push_back('/'); res.append(UUID, 2, AString::npos); diff --git a/src/FurnaceRecipe.cpp b/src/FurnaceRecipe.cpp index 3085d4e46..d315e8182 100644 --- a/src/FurnaceRecipe.cpp +++ b/src/FurnaceRecipe.cpp @@ -6,7 +6,7 @@ #include -#define FURNACE_RECIPE_FILE FILE_IO_PREFIX "furnace.txt" +#define FURNACE_RECIPE_FILE "furnace.txt" diff --git a/src/Globals.h b/src/Globals.h index 387dffc81..02b007e09 100644 --- a/src/Globals.h +++ b/src/Globals.h @@ -190,12 +190,6 @@ template class SizeChecker; #include #endif -#if defined(ANDROID_NDK) - #define FILE_IO_PREFIX "/sdcard/Cuberite/" -#else - #define FILE_IO_PREFIX "" -#endif - diff --git a/src/IniFile.cpp b/src/IniFile.cpp index 2113af0e2..375c9d61f 100644 --- a/src/IniFile.cpp +++ b/src/IniFile.cpp @@ -61,7 +61,7 @@ bool cIniFile::ReadFile(const AString & a_FileName, bool a_AllowExampleRedirect) bool IsFromExampleRedirect = false; - f.open((FILE_IO_PREFIX + a_FileName).c_str(), ios::in); + f.open((a_FileName).c_str(), ios::in); if (f.fail()) { f.clear(); @@ -70,7 +70,7 @@ bool cIniFile::ReadFile(const AString & a_FileName, bool a_AllowExampleRedirect) // Retry with the .example.ini file instead of .ini: AString ExPath(a_FileName.substr(0, a_FileName.length() - 4)); ExPath.append(".example.ini"); - f.open((FILE_IO_PREFIX + ExPath).c_str(), ios::in); + f.open((ExPath).c_str(), ios::in); if (f.fail()) { return false; @@ -176,7 +176,7 @@ bool cIniFile::ReadFile(const AString & a_FileName, bool a_AllowExampleRedirect) if (IsFromExampleRedirect) { - WriteFile(FILE_IO_PREFIX + a_FileName); + WriteFile(a_FileName); } return true; @@ -192,7 +192,7 @@ bool cIniFile::WriteFile(const AString & a_FileName) const // a few bugs with ofstream. So ... fstream used. fstream f; - f.open((FILE_IO_PREFIX + a_FileName).c_str(), ios::out); + f.open((a_FileName).c_str(), ios::out); if (f.fail()) { return false; diff --git a/src/LoggerListeners.cpp b/src/LoggerListeners.cpp index 2028ae151..ffb141a9c 100644 --- a/src/LoggerListeners.cpp +++ b/src/LoggerListeners.cpp @@ -262,9 +262,9 @@ public: bool Open() { // Assume creation succeeds, as the API does not provide a way to tell if the folder exists. - cFile::CreateFolder(FILE_IO_PREFIX "logs"); + cFile::CreateFolder("logs"); bool success = m_File.Open( - FILE_IO_PREFIX + Printf( + Printf( "logs/LOG_%d.txt", std::chrono::duration_cast>>( std::chrono::system_clock::now().time_since_epoch() diff --git a/src/OSSupport/File.cpp b/src/OSSupport/File.cpp index e882daae7..109c51eb7 100644 --- a/src/OSSupport/File.cpp +++ b/src/OSSupport/File.cpp @@ -71,9 +71,9 @@ bool cFile::Open(const AString & iFileName, eMode iMode) } #ifdef _WIN32 - m_File = _fsopen((FILE_IO_PREFIX + iFileName).c_str(), Mode, _SH_DENYWR); + m_File = _fsopen((iFileName).c_str(), Mode, _SH_DENYWR); #else - m_File = fopen((FILE_IO_PREFIX + iFileName).c_str(), Mode); + m_File = fopen((iFileName).c_str(), Mode); #endif // _WIN32 if ((m_File == nullptr) && (iMode == fmReadWrite)) @@ -84,9 +84,9 @@ bool cFile::Open(const AString & iFileName, eMode iMode) // Simply re-open for read-writing, erasing existing contents: #ifdef _WIN32 - m_File = _fsopen((FILE_IO_PREFIX + iFileName).c_str(), "wb+", _SH_DENYWR); + m_File = _fsopen((iFileName).c_str(), "wb+", _SH_DENYWR); #else - m_File = fopen((FILE_IO_PREFIX + iFileName).c_str(), "wb+"); + m_File = fopen((iFileName).c_str(), "wb+"); #endif // _WIN32 } diff --git a/src/Server.cpp b/src/Server.cpp index 6eec68a6e..ab45f6553 100644 --- a/src/Server.cpp +++ b/src/Server.cpp @@ -172,7 +172,7 @@ bool cServer::InitServer(cSettingsRepositoryInterface & a_Settings, bool a_Shoul m_bAllowMultiLogin = a_Settings.GetValueSetB("Server", "AllowMultiLogin", false); m_ResourcePackUrl = a_Settings.GetValueSet("Server", "ResourcePackUrl", ""); - m_FaviconData = Base64Encode(cFile::ReadWholeFile(FILE_IO_PREFIX + AString("favicon.png"))); // Will return empty string if file nonexistant; client doesn't mind + m_FaviconData = Base64Encode(cFile::ReadWholeFile(AString("favicon.png"))); // Will return empty string if file nonexistant; client doesn't mind if (m_bIsConnected) { diff --git a/src/WebAdmin.cpp b/src/WebAdmin.cpp index 9082044fa..eec30235e 100644 --- a/src/WebAdmin.cpp +++ b/src/WebAdmin.cpp @@ -143,7 +143,7 @@ void cWebAdmin::Stop(void) bool cWebAdmin::LoadLoginPage(void) { - cFile File(FILE_IO_PREFIX "webadmin/login_template.html", cFile::fmRead); + cFile File("webadmin/login_template.html", cFile::fmRead); if (!File.IsOpen()) { return false; @@ -198,16 +198,16 @@ void cWebAdmin::Reload(void) } m_TemplateScript.Create(); m_TemplateScript.RegisterAPILibs(); - if (!m_TemplateScript.LoadFile(FILE_IO_PREFIX "webadmin/template.lua")) + if (!m_TemplateScript.LoadFile("webadmin/template.lua")) { - LOGWARN("Could not load WebAdmin template \"%s\". WebAdmin will not work properly!", FILE_IO_PREFIX "webadmin/template.lua"); + LOGWARN("Could not load WebAdmin template \"%s\". WebAdmin will not work properly!", "webadmin/template.lua"); m_TemplateScript.Close(); } // Load the login template, provide a fallback default if not found: if (!LoadLoginPage()) { - LOGWARN("Could not load WebAdmin login page \"%s\", using fallback template.", FILE_IO_PREFIX "webadmin/login_template.html"); + LOGWARN("Could not load WebAdmin login page \"%s\", using fallback template.", "webadmin/login_template.html"); // Set the fallback: m_LoginPage = \ @@ -378,7 +378,7 @@ void cWebAdmin::HandleFileRequest(cHTTPServerConnection & a_Connection, cHTTPInc // Read the file contents and guess its mime-type, based on the extension: AString Content = "

404 Not Found

"; AString ContentType = "text/html"; - AString Path = Printf(FILE_IO_PREFIX "webadmin/files/%s", FileURL.c_str()); + AString Path = Printf("webadmin/files/%s", FileURL.c_str()); // Return 404 if the file is not found, or the URL contains '../' (for security reasons) if ((FileURL.find("../") == AString::npos) && cFile::IsFile(Path)) diff --git a/src/World.cpp b/src/World.cpp index b8a1dcf35..43cb4bf3e 100644 --- a/src/World.cpp +++ b/src/World.cpp @@ -223,7 +223,7 @@ cWorld::cWorld( { LOGD("cWorld::cWorld(\"%s\")", a_WorldName.c_str()); - cFile::CreateFolderRecursive(FILE_IO_PREFIX + m_DataPath); + cFile::CreateFolderRecursive(m_DataPath); m_ChunkMap = cpp14::make_unique(this); m_ChunkMap->TrackInDeadlockDetect(a_DeadlockDetect, m_WorldName); diff --git a/src/WorldStorage/MapSerializer.cpp b/src/WorldStorage/MapSerializer.cpp index 381ef19fa..d030b5a32 100644 --- a/src/WorldStorage/MapSerializer.cpp +++ b/src/WorldStorage/MapSerializer.cpp @@ -23,7 +23,7 @@ cMapSerializer::cMapSerializer(const AString & a_WorldName, cMap * a_Map): Printf(m_Path, "%s%cmap_%i.dat", DataPath.c_str(), cFile::PathSeparator(), a_Map->GetID()); - cFile::CreateFolder(FILE_IO_PREFIX + DataPath); + cFile::CreateFolder(DataPath); } @@ -32,7 +32,7 @@ cMapSerializer::cMapSerializer(const AString & a_WorldName, cMap * a_Map): bool cMapSerializer::Load(void) { - AString Data = cFile::ReadWholeFile(FILE_IO_PREFIX + m_Path); + AString Data = cFile::ReadWholeFile(m_Path); if (Data.empty()) { return false; @@ -75,7 +75,7 @@ bool cMapSerializer::Save(void) #endif // _DEBUG cFile File; - if (!File.Open(FILE_IO_PREFIX + m_Path, cFile::fmWrite)) + if (!File.Open(m_Path, cFile::fmWrite)) { return false; } @@ -207,7 +207,7 @@ cIDCountSerializer::cIDCountSerializer(const AString & a_WorldName) : m_MapCount Printf(m_Path, "%s%cidcounts.dat", DataPath.c_str(), cFile::PathSeparator()); - cFile::CreateFolder(FILE_IO_PREFIX + DataPath); + cFile::CreateFolder(DataPath); } @@ -216,7 +216,7 @@ cIDCountSerializer::cIDCountSerializer(const AString & a_WorldName) : m_MapCount bool cIDCountSerializer::Load(void) { - AString Data = cFile::ReadWholeFile(FILE_IO_PREFIX + m_Path); + AString Data = cFile::ReadWholeFile(m_Path); if (Data.empty()) { return false; @@ -266,7 +266,7 @@ bool cIDCountSerializer::Save(void) #endif // _DEBUG cFile File; - if (!File.Open(FILE_IO_PREFIX + m_Path, cFile::fmWrite)) + if (!File.Open(m_Path, cFile::fmWrite)) { return false; } diff --git a/src/WorldStorage/ScoreboardSerializer.cpp b/src/WorldStorage/ScoreboardSerializer.cpp index 367b88c0d..7b41f92b1 100644 --- a/src/WorldStorage/ScoreboardSerializer.cpp +++ b/src/WorldStorage/ScoreboardSerializer.cpp @@ -22,7 +22,7 @@ cScoreboardSerializer::cScoreboardSerializer(const AString & a_WorldName, cScore m_Path = DataPath + cFile::PathSeparator() + "scoreboard.dat"; - cFile::CreateFolder(FILE_IO_PREFIX + DataPath); + cFile::CreateFolder(DataPath); } @@ -31,7 +31,7 @@ cScoreboardSerializer::cScoreboardSerializer(const AString & a_WorldName, cScore bool cScoreboardSerializer::Load(void) { - AString Data = cFile::ReadWholeFile(FILE_IO_PREFIX + m_Path); + AString Data = cFile::ReadWholeFile(m_Path); if (Data.empty()) { return false; @@ -74,7 +74,7 @@ bool cScoreboardSerializer::Save(void) #endif // _DEBUG cFile File; - if (!File.Open(FILE_IO_PREFIX + m_Path, cFile::fmWrite)) + if (!File.Open(m_Path, cFile::fmWrite)) { return false; } diff --git a/src/WorldStorage/StatSerializer.cpp b/src/WorldStorage/StatSerializer.cpp index ecedd87ce..2bc4b783f 100644 --- a/src/WorldStorage/StatSerializer.cpp +++ b/src/WorldStorage/StatSerializer.cpp @@ -24,7 +24,7 @@ cStatSerializer::cStatSerializer(const AString & a_WorldName, const AString & a_ m_Path = StatsPath + "/" + a_FileName + ".json"; // Ensure that the directory exists. - cFile::CreateFolder(FILE_IO_PREFIX + StatsPath); + cFile::CreateFolder(StatsPath); } @@ -33,10 +33,10 @@ cStatSerializer::cStatSerializer(const AString & a_WorldName, const AString & a_ bool cStatSerializer::Load(void) { - AString Data = cFile::ReadWholeFile(FILE_IO_PREFIX + m_Path); + AString Data = cFile::ReadWholeFile(m_Path); if (Data.empty()) { - Data = cFile::ReadWholeFile(FILE_IO_PREFIX + m_LegacyPath); + Data = cFile::ReadWholeFile(m_LegacyPath); if (Data.empty()) { return false; @@ -64,7 +64,7 @@ bool cStatSerializer::Save(void) SaveStatToJSON(Root); cFile File; - if (!File.Open(FILE_IO_PREFIX + m_Path, cFile::fmWrite)) + if (!File.Open(m_Path, cFile::fmWrite)) { return false; } diff --git a/src/WorldStorage/WSSAnvil.cpp b/src/WorldStorage/WSSAnvil.cpp index e7cd6e544..22564248a 100755 --- a/src/WorldStorage/WSSAnvil.cpp +++ b/src/WorldStorage/WSSAnvil.cpp @@ -112,7 +112,7 @@ cWSSAnvil::cWSSAnvil(cWorld * a_World, int a_CompressionFactor) : Writer.EndCompound(); Writer.Finish(); - gzFile gz = gzopen((FILE_IO_PREFIX + fnam).c_str(), "wb"); + gzFile gz = gzopen((fnam).c_str(), "wb"); if (gz != nullptr) { gzwrite(gz, Writer.GetResult().data(), static_cast(Writer.GetResult().size())); @@ -181,7 +181,7 @@ void cWSSAnvil::ChunkLoadFailed(int a_ChunkX, int a_ChunkZ, const AString & a_Re // Construct the filename for offloading: AString OffloadFileName; Printf(OffloadFileName, "%s%cregion%cbadchunks", m_World->GetDataPath().c_str(), cFile::PathSeparator(), cFile::PathSeparator()); - cFile::CreateFolder(FILE_IO_PREFIX + OffloadFileName); + cFile::CreateFolder(OffloadFileName); auto t = time(nullptr); struct tm stm; #ifdef _MSC_VER @@ -287,7 +287,7 @@ cWSSAnvil::cMCAFile * cWSSAnvil::LoadMCAFile(const cChunkCoords & a_Chunk) // Load it anew: AString FileName; Printf(FileName, "%s%cregion", m_World->GetDataPath().c_str(), cFile::PathSeparator()); - cFile::CreateFolder(FILE_IO_PREFIX + FileName); + cFile::CreateFolder(FileName); AppendPrintf(FileName, "/r.%d.%d.mca", RegionX, RegionZ); cMCAFile * f = new cMCAFile(*this, FileName, RegionX, RegionZ); if (f == nullptr) -- cgit v1.2.3