Replace usage of OSString().c_str() by OSString

Fixes #6604
This commit is contained in:
Stan
2024-10-27 11:33:42 +01:00
parent ff28ac36a6
commit 6d12d25348
12 changed files with 30 additions and 30 deletions
@@ -217,7 +217,7 @@ int wclosedir(WDIR* d)
int wopen(const OsPath& pathname, int oflag)
{
ENSURE(!(oflag & O_CREAT)); // must specify mode_arg if O_CREAT
return wopen(OsString(pathname).c_str(), oflag, _S_IREAD|_S_IWRITE);
return wopen(OsString(pathname), oflag, _S_IREAD|_S_IWRITE);
}
+3 -3
View File
@@ -1,4 +1,4 @@
/* Copyright (C) 2021 Wildfire Games.
/* Copyright (C) 2024 Wildfire Games.
* This file is part of 0 A.D.
*
* 0 A.D. is free software: you can redistribute it and/or modify
@@ -114,13 +114,13 @@ void CNetClientTurnManager::OnSyncError(u32 turn, const CStr& expectedHash, cons
ENSURE(m_Simulation2.ComputeStateHash(hash, !TurnNeedsFullHash(turn)));
OsPath oosdumpPath(psLogDir() / (L"oos_dump" + g_UniqueLogPostfix + L".txt"));
std::ofstream file (OsString(oosdumpPath).c_str(), std::ofstream::out | std::ofstream::trunc);
std::ofstream file (OsString(oosdumpPath), std::ofstream::out | std::ofstream::trunc);
file << "oos turn: " << turn << std::endl;
file << "net client turn: " << m_CurrentTurn << std::endl;
m_Simulation2.DumpDebugState(file);
file.close();
std::ofstream binfile (OsString(oosdumpPath.ChangeExtension(L".dat")).c_str(), std::ofstream::out | std::ofstream::trunc | std::ofstream::binary);
std::ofstream binfile (OsString(oosdumpPath.ChangeExtension(L".dat")), std::ofstream::out | std::ofstream::trunc | std::ofstream::binary);
m_Simulation2.SerializeState(binfile);
binfile.close();
+1 -1
View File
@@ -291,7 +291,7 @@ std::ofstream OpenLogFile(const wchar_t* filePrefix, const char* logName)
{
OsPath path{psLogDir() / (filePrefix + g_UniqueLogPostfix + L".html")};
debug_printf("FILES| %s written to '%s'\n", logName, path.string8().c_str());
return std::ofstream{OsString(path).c_str(), std::ofstream::trunc};
return std::ofstream{OsString(path), std::ofstream::trunc};
}
}
+1 -1
View File
@@ -186,7 +186,7 @@ bool CGame::StartVisualReplay(const OsPath& replayPath)
SetTurnManager(new CReplayTurnManager(*m_Simulation2, GetReplayLogger()));
m_ReplayPath = replayPath;
m_ReplayStream = new std::ifstream(OsString(replayPath).c_str());
m_ReplayStream = new std::ifstream(OsString(replayPath));
std::string type;
ENSURE((*m_ReplayStream >> type).good() && type == "start");
+2 -2
View File
@@ -1,4 +1,4 @@
/* Copyright (C) 2022 Wildfire Games.
/* Copyright (C) 2024 Wildfire Games.
* This file is part of 0 A.D.
*
* 0 A.D. is free software: you can redistribute it and/or modify
@@ -517,7 +517,7 @@ void CProfileViewer::SaveToFile()
// Open the file. (It will be closed when the CProfileViewer
// destructor is called.)
OsPath path = psLogDir()/"profile.txt";
m->outputStream.open(OsString(path).c_str(), std::ofstream::out | std::ofstream::trunc);
m->outputStream.open(OsString(path), std::ofstream::out | std::ofstream::trunc);
if (m->outputStream.fail())
{
+1 -1
View File
@@ -938,7 +938,7 @@ void CProfiler2::SaveToFile()
OsPath path = psLogDir()/"profile2.jsonp";
debug_printf("Writing profile data to %s \n", path.string8().c_str());
LOGMESSAGERENDER("Writing profile data to %s \n", path.string8().c_str());
std::ofstream stream(OsString(path).c_str(), std::ofstream::out | std::ofstream::trunc);
std::ofstream stream(OsString(path), std::ofstream::out | std::ofstream::trunc);
ENSURE(stream.good());
stream << "profileDataCB({\"threads\": [\n";
+4 -4
View File
@@ -1,4 +1,4 @@
/* Copyright (C) 2022 Wildfire Games.
/* Copyright (C) 2024 Wildfire Games.
* This file is part of 0 A.D.
*
* 0 A.D. is free software: you can redistribute it and/or modify
@@ -84,7 +84,7 @@ void CReplayLogger::StartGame(JS::MutableHandleValue attribs)
m_Directory = createDateIndexSubdirectory(VisualReplay::GetDirectoryPath());
debug_printf("FILES| Replay written to '%s'\n", m_Directory.string8().c_str());
m_Stream = new std::ofstream(OsString(m_Directory / L"commands.txt").c_str(), std::ofstream::out | std::ofstream::trunc);
m_Stream = new std::ofstream(OsString(m_Directory / L"commands.txt"), std::ofstream::out | std::ofstream::trunc);
*m_Stream << "start " << Script::StringifyJSON(rq, attribs, false) << "\n";
}
@@ -128,7 +128,7 @@ void CReplayLogger::SaveMetadata(const CSimulation2& simulation)
const OsPath fileName = g_Game->GetReplayLogger().GetDirectory() / L"metadata.json";
CreateDirectories(fileName.Parent(), 0700);
std::ofstream stream (OsString(fileName).c_str(), std::ofstream::out | std::ofstream::trunc);
std::ofstream stream (OsString(fileName), std::ofstream::out | std::ofstream::trunc);
if (stream)
{
stream << Script::StringifyJSON(rq, &metadata, false);
@@ -161,7 +161,7 @@ void CReplayPlayer::Load(const OsPath& path)
{
ENSURE(!m_Stream);
m_Stream = new std::ifstream(OsString(path).c_str());
m_Stream = new std::ifstream(OsString(path));
ENSURE(m_Stream->good());
}
+6 -6
View File
@@ -1,4 +1,4 @@
/* Copyright (C) 2021 Wildfire Games.
/* Copyright (C) 2024 Wildfire Games.
* This file is part of 0 A.D.
*
* 0 A.D. is free software: you can redistribute it and/or modify
@@ -79,7 +79,7 @@ bool VisualReplay::ReadCacheFile(const ScriptInterface& scriptInterface, JS::Mut
if (!FileExists(GetCacheFilePath()))
return false;
std::ifstream cacheStream(OsString(GetCacheFilePath()).c_str());
std::ifstream cacheStream(OsString(GetCacheFilePath()));
CStr cacheStr((std::istreambuf_iterator<char>(cacheStream)), std::istreambuf_iterator<char>());
cacheStream.close();
@@ -104,7 +104,7 @@ void VisualReplay::StoreCacheFile(const ScriptInterface& scriptInterface, JS::Ha
ScriptRequest rq(scriptInterface);
JS::RootedValue replaysRooted(rq.cx, JS::ObjectValue(*replays));
std::ofstream cacheStream(OsString(GetTempCacheFilePath()).c_str(), std::ofstream::out | std::ofstream::trunc);
std::ofstream cacheStream(OsString(GetTempCacheFilePath()), std::ofstream::out | std::ofstream::trunc);
cacheStream << Script::StringifyJSON(rq, &replaysRooted);
cacheStream.close();
@@ -354,7 +354,7 @@ JS::Value VisualReplay::LoadReplayData(const ScriptInterface& scriptInterface, c
if (fileSize == 0)
return JS::NullValue();
std::ifstream* replayStream = new std::ifstream(OsString(replayFile).c_str());
std::ifstream* replayStream = new std::ifstream(OsString(replayFile));
CStr type;
if (!(*replayStream >> type).good())
@@ -445,7 +445,7 @@ JS::Value VisualReplay::GetReplayAttributes(const ScriptInterface& scriptInterfa
return attribs;
// Open file
std::istream* replayStream = new std::ifstream(OsString(replayFile).c_str());
std::istream* replayStream = new std::ifstream(OsString(replayFile));
CStr type, line;
ENSURE((*replayStream >> type).good() && type == "start");
@@ -497,7 +497,7 @@ JS::Value VisualReplay::GetReplayMetadata(const ScriptInterface& scriptInterface
ScriptRequest rq(scriptInterface);
JS::RootedValue metadata(rq.cx);
std::ifstream* stream = new std::ifstream(OsString(GetDirectoryPath() / directoryName / L"metadata.json").c_str());
std::ifstream* stream = new std::ifstream(OsString(GetDirectoryPath() / directoryName / L"metadata.json"));
ENSURE(stream->good());
CStr line;
std::getline(*stream, line);
+5 -5
View File
@@ -282,19 +282,19 @@ void CSimulation2Impl::DumpSerializationTestState(SerializationTestState& state,
{
if (!state.hash.empty())
{
std::ofstream file (OsString(path / (L"hash." + suffix)).c_str(), std::ofstream::out | std::ofstream::trunc);
std::ofstream file (OsString(path / (L"hash." + suffix)), std::ofstream::out | std::ofstream::trunc);
file << Hexify(state.hash);
}
if (!state.debug.str().empty())
{
std::ofstream file (OsString(path / (L"debug." + suffix)).c_str(), std::ofstream::out | std::ofstream::trunc);
std::ofstream file (OsString(path / (L"debug." + suffix)), std::ofstream::out | std::ofstream::trunc);
file << state.debug.str();
}
if (!state.state.str().empty())
{
std::ofstream file (OsString(path / (L"state." + suffix)).c_str(), std::ofstream::out | std::ofstream::trunc | std::ofstream::binary);
std::ofstream file (OsString(path / (L"state." + suffix)), std::ofstream::out | std::ofstream::trunc | std::ofstream::binary);
file << state.state.str();
}
}
@@ -609,7 +609,7 @@ void CSimulation2Impl::DumpState()
std::stringstream name;\
name << std::setw(5) << std::setfill('0') << m_TurnNumber << ".txt";
const OsPath path = m_OOSLogPath / name.str();
std::ofstream file (OsString(path).c_str(), std::ofstream::out | std::ofstream::trunc);
std::ofstream file (OsString(path), std::ofstream::out | std::ofstream::trunc);
if (!DirectoryExists(m_OOSLogPath))
{
@@ -628,7 +628,7 @@ void CSimulation2Impl::DumpState()
m_ComponentManager.DumpDebugState(file, true);
std::ofstream binfile (OsString(path.ChangeExtension(L".dat")).c_str(), std::ofstream::out | std::ofstream::trunc | std::ofstream::binary);
std::ofstream binfile (OsString(path.ChangeExtension(L".dat")), std::ofstream::out | std::ofstream::trunc | std::ofstream::binary);
m_ComponentManager.SerializeState(binfile);
}
@@ -269,7 +269,7 @@ public:
sim2.InitGame();
sim2.Update(0);
std::ofstream stream(OsString("perf2.html").c_str(), std::ofstream::out | std::ofstream::trunc);
std::ofstream stream(OsString("perf2.html"), std::ofstream::out | std::ofstream::trunc);
CmpPtr<ICmpObstructionManager> cmpObstructionManager(sim2, SYSTEM_ENTITY);
CmpPtr<ICmpPathfinder> cmpPathfinder(sim2, SYSTEM_ENTITY);
@@ -326,7 +326,7 @@ public:
sim2.InitGame();
sim2.Update(0);
std::ofstream stream(OsString("perf3.html").c_str(), std::ofstream::out | std::ofstream::trunc);
std::ofstream stream(OsString("perf3.html"), std::ofstream::out | std::ofstream::trunc);
CmpPtr<ICmpObstructionManager> cmpObstructionManager(sim2, SYSTEM_ENTITY);
CmpPtr<ICmpPathfinder> cmpPathfinder(sim2, SYSTEM_ENTITY);
@@ -1,4 +1,4 @@
/* Copyright (C) 2023 Wildfire Games.
/* Copyright (C) 2024 Wildfire Games.
* This file is part of 0 A.D.
*
* 0 A.D. is free software: you can redistribute it and/or modify
@@ -84,7 +84,7 @@ void PostNetworkCommand(const ScriptInterface& scriptInterface, JS::HandleValue
void DumpSimState()
{
OsPath path = psLogDir()/"sim_dump.txt";
std::ofstream file (OsString(path).c_str(), std::ofstream::out | std::ofstream::trunc);
std::ofstream file (OsString(path), std::ofstream::out | std::ofstream::trunc);
g_Game->GetSimulation2()->DumpDebugState(file);
}
+2 -2
View File
@@ -1,4 +1,4 @@
/* Copyright (C) 2023 Wildfire Games.
/* Copyright (C) 2024 Wildfire Games.
* This file is part of 0 A.D.
*
* 0 A.D. is free software: you can redistribute it and/or modify
@@ -147,7 +147,7 @@ void ScriptTestSetup(const ScriptInterface& scriptInterface)
// Load the TS_* function definitions
// (We don't use VFS because tests might not have the normal VFS paths loaded)
OsPath path = DataDir()/"tests"/"test_setup.js";
std::ifstream ifs(OsString(path).c_str());
std::ifstream ifs(OsString(path));
ENSURE(ifs.good());
std::string content((std::istreambuf_iterator<char>(ifs)), std::istreambuf_iterator<char>());
ENSURE(scriptInterface.LoadScript(L"test_setup.js", content));