1
0

Remove old Android leftovers (#4722)

This commit is contained in:
Mat 2020-05-07 22:14:00 +03:00 committed by GitHub
parent f3b4183dc2
commit c710f6a4ea
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
22 changed files with 40 additions and 108 deletions

View File

@ -148,12 +148,6 @@ typedef unsigned short UInt16;
#define FILE_IO_PREFIX ""
// CRT stuff:
#include <sys/stat.h>
#include <assert.h>

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -209,12 +209,6 @@ template class SizeChecker<UInt16, 2>;
#include <fcntl.h>
#endif
#if defined(ANDROID_NDK)
#define FILE_IO_PREFIX "/sdcard/mcserver/"
#else
#define FILE_IO_PREFIX ""
#endif

View File

@ -166,16 +166,6 @@ typedef unsigned char Byte;
#include <fcntl.h>
#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

View File

@ -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());

View File

@ -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;

View File

@ -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);

View File

@ -6,7 +6,7 @@
#include <fstream>
#define FURNACE_RECIPE_FILE FILE_IO_PREFIX "furnace.txt"
#define FURNACE_RECIPE_FILE "furnace.txt"

View File

@ -190,12 +190,6 @@ template class SizeChecker<UInt8, 1>;
#include <unistd.h>
#endif
#if defined(ANDROID_NDK)
#define FILE_IO_PREFIX "/sdcard/Cuberite/"
#else
#define FILE_IO_PREFIX ""
#endif

View File

@ -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;

View File

@ -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::duration<int, std::ratio<1>>>(
std::chrono::system_clock::now().time_since_epoch()

View File

@ -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
}

View File

@ -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)
{

View File

@ -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 = "<h2>404 Not Found</h2>";
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))

View File

@ -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<cChunkMap>(this);
m_ChunkMap->TrackInDeadlockDetect(a_DeadlockDetect, m_WorldName);

View File

@ -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;
}

View File

@ -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;
}

View File

@ -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;
}

View File

@ -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<unsigned>(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)