Opened 21 months ago

Last modified 16 months ago

#6604 new defect

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

Reported by: Stan Owned by:
Priority: Should Have Milestone: Backlog
Component: Core engine Keywords:
Cc: Patch:

Description

Since c++11, *fstream can use std::string or on Windows std::wstring as parameter. Converting to char* is no longer required.

(void)_wfopen_s(&f, OsString(pathname).c_str(), wmode.c_str());	source\lib\sysdep\os\win\wsysdep.cpp	640	22
const DWORD fileAttributes = GetFileAttributesW(OsString(path).c_str());	source\lib\sysdep\os\win\wposix\wfilesystem.cpp	88	50
const DWORD ver_size = GetFileVersionInfoSizeW(OsString(modulePathname).c_str(), &unused);	// [bytes]	source\lib\sysdep\os\win\wdll_ver.cpp	51	49
d->hFind = FindFirstFileW(OsString(searchPath).c_str(), &d->findData);	source\lib\sysdep\os\win\wposix\wfilesystem.cpp	125	28
errno_t ret = _wsopen_s(&fd, OsString(pathname).c_str(), oflag, _SH_DENYRD, mode);	source\lib\sysdep\os\win\wposix\wfilesystem.cpp	235	32
HANDLE hFile = CreateFileW(OsString(path).c_str(), GENERIC_WRITE, FILE_SHARE_WRITE, 0, CREATE_ALWAYS, 0, 0);	source\lib\sysdep\os\win\wdbg_sym.cpp	1764	29
HANDLE hFile = CreateFileW(OsString(pathname).c_str(), GENERIC_WRITE, 0, 0, OPEN_EXISTING, 0, 0);	source\lib\sysdep\os\win\wposix\wfilesystem.cpp	286	29
hFile = CreateFileW(OsString(pathname).c_str(), access, share, 0, create, flags, 0);	source\lib\sysdep\os\win\wposix\waio.cpp	126	22
HMODULE hDbghelp = LoadLibraryW(OsString(pathname).c_str());	source\lib\external_libraries\dbghelp.cpp	47	34
HMODULE hModule = LoadLibraryExW(OsString(modulePathname).c_str(), 0, LOAD_LIBRARY_AS_DATAFILE);	source\lib\sysdep\os\win\wdll_ver.cpp	56	36
HMODULE hModule = LoadLibraryW(OsString(pathname).c_str());	source\lib\sysdep\os\win\wposix\wdlfcn.cpp	69	33
if(!CreateDirectoryW(OsString(path).c_str(), (LPSECURITY_ATTRIBUTES)NULL))	source\lib\sysdep\os\win\wposix\wfilesystem.cpp	338	23
if(!GetFileVersionInfoW(OsString(modulePathname).c_str(), 0, ver_size, mem.get()))	source\lib\sysdep\os\win\wdll_ver.cpp	64	26
if(!GetFullPathNameW(OsString(pathname).c_str(), PATH_MAX, resolved, 0))	source\lib\sysdep\os\win\wposix\wfilesystem.cpp	311	23
if(path_is_subpath(OsString(path).c_str(), OsString(existingDirWatch->request->Path()).c_str()))	source\lib\sysdep\os\win\wdir_watch.cpp	319	23
m_hDir = CreateFileW(OsString(path).c_str(), FILE_LIST_DIRECTORY, share, 0, OPEN_EXISTING, flags, 0);	source\lib\sysdep\os\win\wdir_watch.cpp	53	24
m_InterestingLog = new std::ofstream(OsString(interestinglogPath).c_str(), std::ofstream::out | std::ofstream::trunc);	source\ps\CLogger.cpp	77	39
m_MainLog = new std::ofstream(OsString(mainlogPath).c_str(), std::ofstream::out | std::ofstream::trunc);	source\ps\CLogger.cpp	73	32
m_ReplayStream = new std::ifstream(OsString(replayPath).c_str());	source\ps\Game.cpp	187	37
m_Stream = new std::ifstream(OsString(path).c_str());	source\ps\Replay.cpp	164	31
m_Stream = new std::ofstream(OsString(m_Directory / L"commands.txt").c_str(), std::ofstream::out | std::ofstream::trunc);	source\ps\Replay.cpp	87	31
m->outputStream.open(OsString(path).c_str(), std::ofstream::out | std::ofstream::trunc);	source\ps\ProfileViewer.cpp	521	24
return _wrmdir(OsString(path).c_str());	source\lib\sysdep\os\win\wposix\wfilesystem.cpp	304	17
return _wstat64(OsString(pathname).c_str(), buf);	source\lib\sysdep\os\win\wposix\wfilesystem.cpp	350	18
return _wunlink(OsString(pathname).c_str());	source\lib\sysdep\os\win\wposix\wfilesystem.cpp	298	18
return wopen(OsString(pathname).c_str(), oflag, _S_IREAD|_S_IWRITE);	source\lib\sysdep\os\win\wposix\wfilesystem.cpp	211	15
std::ifstream ifs(OsString(path).c_str());	source\test_setup.cpp	160	20
std::ifstream* replayStream = new std::ifstream(OsString(replayFile).c_str());	source\ps\VisualReplay.cpp	357	50
std::istream* replayStream = new std::ifstream(OsString(replayFile).c_str());	source\ps\VisualReplay.cpp	448	49
std::ofstream file (OsString(oosdumpPath).c_str(), std::ofstream::out | std::ofstream::trunc);	source\network\NetClientTurnManager.cpp	117	22
std::ofstream file (OsString(path).c_str(), std::ofstream::out | std::ofstream::trunc);	source\simulation2\scripting\JSInterface_Simulation.cpp	86	22
std::ofstream file (OsString(path).c_str(), std::ofstream::out | std::ofstream::trunc);	source\simulation2\Simulation2.cpp	611	22
std::ofstream stream (OsString(fileName).c_str(), std::ofstream::out | std::ofstream::trunc);	source\ps\Replay.cpp	131	24
std::ofstream stream(OsString("perf2.html").c_str(), std::ofstream::out | std::ofstream::trunc);	source\simulation2\components\tests\test_Pathfinder.h	272	24
std::ofstream stream(OsString("perf3.html").c_str(), std::ofstream::out | std::ofstream::trunc);	source\simulation2\components\tests\test_Pathfinder.h	329	24
std::ofstream stream(OsString(path).c_str(), std::ofstream::out | std::ofstream::trunc);	source\ps\Profiler2.cpp	942	23

Note some of the elements above are false positives, or should be replaced by STL calls instead of low-level ones.

Change History (3)

comment:1 by phosit, 21 months ago

Will this be done in a26? I hope we can replace them with std::filesystem::path in a27.

comment:2 by Stan, 21 months ago

Milestone: Alpha 26Alpha 27

We can't use std::filepath for all platforms until we switch to the macOS 10.15 SDK and we can't do that until we switch to vulkan/metal, because they broken OpenGL performance in it.

comment:3 by Freagarach, 16 months ago

Milestone: Alpha 27Backlog

Pushing back.

Note: See TracTickets for help on using tickets.