Fix MSVC compilation due to macros in Windows API headers
There exists `CreateDirectory` `#define` somewhere and it results in failed compilation of `resourcemanager.cpp`. Similarly for `RemoveDirectory`. See https://docs.microsoft.com/en-us/windows/win32/api/fileapi/nf-fileapi-createdirectorya Rename the two methods to remove the conflict. The fail occurs at least when using Visual Studio 2022 Preview.fix-squashed-planets
parent
8f0b367f9c
commit
bbf5c806d8
|
@ -176,7 +176,7 @@ void CSignalHandlers::ReportError(const std::string& errorMessage)
|
|||
if (result == SDR_YES)
|
||||
{
|
||||
triedSaving = true;
|
||||
CResourceManager::CreateDirectory("crashsave");
|
||||
CResourceManager::CreateNewDirectory("crashsave");
|
||||
robotMain->IOWriteScene("crashsave/data.sav", "crashsave/cbot.run", "crashsave/screen.png", "Backup at the moment of a crash", true);
|
||||
m_systemUtils->SystemDialog(SDT_INFO, "Try to save?", "Saving finished.\nPlease restart the game now");
|
||||
}
|
||||
|
|
|
@ -156,7 +156,7 @@ bool CResourceManager::DirectoryExists(const std::string& directory)
|
|||
return false;
|
||||
}
|
||||
|
||||
bool CResourceManager::CreateDirectory(const std::string& directory)
|
||||
bool CResourceManager::CreateNewDirectory(const std::string& directory)
|
||||
{
|
||||
if (PHYSFS_isInit())
|
||||
{
|
||||
|
@ -165,7 +165,7 @@ bool CResourceManager::CreateDirectory(const std::string& directory)
|
|||
return false;
|
||||
}
|
||||
|
||||
bool CResourceManager::RemoveDirectory(const std::string& directory)
|
||||
bool CResourceManager::RemoveExistingDirectory(const std::string& directory)
|
||||
{
|
||||
if (PHYSFS_isInit())
|
||||
{
|
||||
|
|
|
@ -57,9 +57,9 @@ public:
|
|||
static bool DirectoryExists(const std::string& directory);
|
||||
|
||||
//! Create directory in write directory
|
||||
static bool CreateDirectory(const std::string& directory);
|
||||
static bool CreateNewDirectory(const std::string& directory);
|
||||
//! Remove directory in write directory, recursively
|
||||
static bool RemoveDirectory(const std::string& directory);
|
||||
static bool RemoveExistingDirectory(const std::string& directory);
|
||||
|
||||
//! List files contained in directory
|
||||
static std::vector<std::string> ListFiles(const std::string &directory, bool excludeDirs = false);
|
||||
|
|
|
@ -148,14 +148,14 @@ bool CPlayerProfile::Create()
|
|||
{
|
||||
if (!CResourceManager::DirectoryExists(GetSaveDir()))
|
||||
{
|
||||
return CResourceManager::CreateDirectory(GetSaveDir());
|
||||
return CResourceManager::CreateNewDirectory(GetSaveDir());
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
bool CPlayerProfile::Delete()
|
||||
{
|
||||
return CResourceManager::RemoveDirectory(GetSaveDir());
|
||||
return CResourceManager::RemoveExistingDirectory(GetSaveDir());
|
||||
}
|
||||
|
||||
std::string CPlayerProfile::GetName()
|
||||
|
@ -507,7 +507,7 @@ void CPlayerProfile::SaveScene(std::string dir, std::string info)
|
|||
{
|
||||
if (!CResourceManager::DirectoryExists(dir))
|
||||
{
|
||||
CResourceManager::CreateDirectory(dir);
|
||||
CResourceManager::CreateNewDirectory(dir);
|
||||
}
|
||||
|
||||
CRobotMain::GetInstancePointer()->IOWriteScene(dir + "/data.sav", dir + "/cbot.run", dir + "/screen.png", info.c_str());
|
||||
|
@ -568,7 +568,7 @@ bool CPlayerProfile::DeleteScene(std::string dir)
|
|||
{
|
||||
if (CResourceManager::DirectoryExists(dir))
|
||||
{
|
||||
return CResourceManager::RemoveDirectory(dir);
|
||||
return CResourceManager::RemoveExistingDirectory(dir);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
|
|
@ -504,12 +504,12 @@ void CRobotMain::ChangePhase(Phase phase)
|
|||
GetLogger()->Info("Trying to restore pre-crash state...\n");
|
||||
assert(m_playerProfile != nullptr);
|
||||
m_playerProfile->LoadScene("../../crashsave");
|
||||
CResourceManager::RemoveDirectory("crashsave");
|
||||
CResourceManager::RemoveExistingDirectory("crashsave");
|
||||
},
|
||||
[&]()
|
||||
{
|
||||
GetLogger()->Info("Not restoring pre-crash state\n");
|
||||
CResourceManager::RemoveDirectory("crashsave");
|
||||
CResourceManager::RemoveExistingDirectory("crashsave");
|
||||
}
|
||||
);
|
||||
}
|
||||
|
@ -5766,7 +5766,7 @@ void CRobotMain::AutosaveRotate()
|
|||
std::sort(autosaves.begin(), autosaves.end(), std::less<std::string>());
|
||||
for (int i = 0; i < static_cast<int>(autosaves.size()) - m_autosaveSlots + 1; i++)
|
||||
{
|
||||
CResourceManager::RemoveDirectory(m_playerProfile->GetSaveDir() + "/" + autosaves[i]);
|
||||
CResourceManager::RemoveExistingDirectory(m_playerProfile->GetSaveDir() + "/" + autosaves[i]);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -3400,7 +3400,7 @@ public:
|
|||
private:
|
||||
static std::string PrepareFilename(const std::string& filename)
|
||||
{
|
||||
CResourceManager::CreateDirectory("files");
|
||||
CResourceManager::CreateNewDirectory("files");
|
||||
return "files/" + filename;
|
||||
}
|
||||
};
|
||||
|
|
|
@ -1090,7 +1090,7 @@ std::string CFileDialog::SearchDirectory(bool bCreate)
|
|||
|
||||
if (bCreate && !CResourceManager::DirectoryExists(dir))
|
||||
{
|
||||
CResourceManager::CreateDirectory(dir);
|
||||
CResourceManager::CreateNewDirectory(dir);
|
||||
}
|
||||
|
||||
if (!m_subDirPath.empty())
|
||||
|
@ -1098,7 +1098,7 @@ std::string CFileDialog::SearchDirectory(bool bCreate)
|
|||
dir += "/" + m_subDirPath;
|
||||
if (bCreate && !CResourceManager::DirectoryExists(dir))
|
||||
{
|
||||
CResourceManager::CreateDirectory(dir);
|
||||
CResourceManager::CreateNewDirectory(dir);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue