From 50deb54bff418742821281c580eda9213fc27792 Mon Sep 17 00:00:00 2001 From: Hleb Valoshka <375gnu@gmail.com> Date: Thu, 16 Dec 2021 17:16:36 +0200 Subject: [PATCH] Remove unneeded fs::path.string() conversions --- src/cel3ds/3dsread.cpp | 2 +- src/celengine/mapmanager.cpp | 2 +- src/celengine/meshmanager.cpp | 6 +++--- src/celengine/rotationmanager.cpp | 2 +- src/celengine/shadermanager.cpp | 4 ++-- src/celengine/texmanager.cpp | 2 +- src/celengine/trajmanager.cpp | 2 +- src/celengine/virtualtex.cpp | 2 +- src/celephem/samporbit.cpp | 6 +++--- src/celephem/samporient.cpp | 2 +- src/celestia/celestiacore.cpp | 28 +++++++++++++-------------- src/celestia/configfile.cpp | 2 +- src/celestia/qt/qtappwin.cpp | 2 +- src/celestia/scriptmenu.cpp | 2 +- src/celestia/win32/winmain.cpp | 2 +- src/celimage/dds.cpp | 2 +- src/celscript/legacy/legacyscript.cpp | 2 +- src/celscript/lua/luascript.cpp | 4 ++-- 18 files changed, 37 insertions(+), 37 deletions(-) diff --git a/src/cel3ds/3dsread.cpp b/src/cel3ds/3dsread.cpp index 1ad8a93c1..1e5e5a45c 100644 --- a/src/cel3ds/3dsread.cpp +++ b/src/cel3ds/3dsread.cpp @@ -605,7 +605,7 @@ std::unique_ptr Read3DSFile(std::istream& in) std::unique_ptr Read3DSFile(const fs::path& filename) { - std::ifstream in(filename.string(), std::ios::in | std::ios::binary); + std::ifstream in(filename, std::ios::in | std::ios::binary); if (!in.good()) { GetLogger()->error("Read3DSFile: Error opening {}\n", filename); diff --git a/src/celengine/mapmanager.cpp b/src/celengine/mapmanager.cpp index fd6f2f4bf..efbc7f023 100644 --- a/src/celengine/mapmanager.cpp +++ b/src/celengine/mapmanager.cpp @@ -141,7 +141,7 @@ fs::path WarpMeshInfo::resolve(const fs::path& baseDir) WarpMesh* WarpMeshInfo::load(const fs::path& name) { #define MESHTYPE_RECT 2 - ifstream f(name.string()); + ifstream f(name); if (!f.good()) return nullptr; diff --git a/src/celengine/meshmanager.cpp b/src/celengine/meshmanager.cpp index f8cce26da..134c0d6f5 100644 --- a/src/celengine/meshmanager.cpp +++ b/src/celengine/meshmanager.cpp @@ -82,7 +82,7 @@ NoiseDisplacementFunc(float u, float v, void* info) std::unique_ptr LoadCelestiaMesh(const fs::path& filename) { - std::ifstream meshFile(filename.string(), std::ios::in); + std::ifstream meshFile(filename, std::ios::in); if (!meshFile.good()) { GetLogger()->error("Error opening mesh file: {}\n", filename); @@ -439,7 +439,7 @@ GeometryInfo::resolve(const fs::path& baseDir) if (!path.empty()) { fs::path filename = path / "models" / source; - std::ifstream in(filename.string()); + std::ifstream in(filename); if (in.good()) { resolvedToPath = true; @@ -480,7 +480,7 @@ GeometryInfo::load(const fs::path& resolvedFilename) } else if (fileType == Content_CelestiaModel) { - std::ifstream in(filename.string(), std::ios::binary); + std::ifstream in(filename, std::ios::binary); if (in.good()) { model = cmod::LoadModel( diff --git a/src/celengine/rotationmanager.cpp b/src/celengine/rotationmanager.cpp index 1d7a5a80f..4a91c327c 100644 --- a/src/celengine/rotationmanager.cpp +++ b/src/celengine/rotationmanager.cpp @@ -33,7 +33,7 @@ fs::path RotationModelInfo::resolve(const fs::path& baseDir) if (!path.empty()) { fs::path filename = path / "data" / source; - ifstream in(filename.string()); + ifstream in(filename); if (in.good()) return filename; } diff --git a/src/celengine/shadermanager.cpp b/src/celengine/shadermanager.cpp index 7c9ae0e98..6ec0f6a8a 100644 --- a/src/celengine/shadermanager.cpp +++ b/src/celengine/shadermanager.cpp @@ -414,14 +414,14 @@ ShaderManager::getShader(const string& name) return getShader(name, errorVertexShaderSource, errorFragmentShaderSource); } - ifstream vsf(vsName.string()); + ifstream vsf(vsName); if (!vsf.good()) { GetLogger()->error("Failed to open {}\n", vsName); return getShader(name, errorVertexShaderSource, errorFragmentShaderSource); } - ifstream fsf(fsName.string()); + ifstream fsf(fsName); if (!fsf.good()) { GetLogger()->error("Failed to open {}\n", fsName); diff --git a/src/celengine/texmanager.cpp b/src/celengine/texmanager.cpp index b92568294..5abf527e7 100644 --- a/src/celengine/texmanager.cpp +++ b/src/celengine/texmanager.cpp @@ -69,7 +69,7 @@ fs::path TextureInfo::resolve(const fs::path& baseDir) } else { - ifstream in(filename.string()); + ifstream in(filename); if (in.good()) return filename; } diff --git a/src/celengine/trajmanager.cpp b/src/celengine/trajmanager.cpp index 7e19f7348..a1fba629c 100644 --- a/src/celengine/trajmanager.cpp +++ b/src/celengine/trajmanager.cpp @@ -48,7 +48,7 @@ fs::path TrajectoryInfo::resolve(const fs::path& baseDir) if (!path.empty()) { fs::path filename = path / "data" / source; - ifstream in(filename.string()); + ifstream in(filename); if (in.good()) return filename += uniquifyingSuffix; } diff --git a/src/celengine/virtualtex.cpp b/src/celengine/virtualtex.cpp index 693c5e8b8..9ff88f4b0 100644 --- a/src/celengine/virtualtex.cpp +++ b/src/celengine/virtualtex.cpp @@ -395,7 +395,7 @@ static VirtualTexture* LoadVirtualTexture(istream& in, const fs::path& path) VirtualTexture* LoadVirtualTexture(const fs::path& filename) { - ifstream in(filename.string(), ios::in); + ifstream in(filename, ios::in); if (!in.good()) { diff --git a/src/celephem/samporbit.cpp b/src/celephem/samporbit.cpp index cc76e13bf..ab0775572 100644 --- a/src/celephem/samporbit.cpp +++ b/src/celephem/samporbit.cpp @@ -726,7 +726,7 @@ static bool SkipComments(istream& in) template SampledOrbit* LoadSampledOrbit(const fs::path& filename, TrajectoryInterpolation interpolation, T /*unused*/) { - ifstream in(filename.string()); + ifstream in(filename); if (!in.good()) return nullptr; @@ -781,7 +781,7 @@ template SampledOrbit* LoadSampledOrbit(const fs::path& filename template SampledOrbitXYZV* LoadSampledOrbitXYZV(const fs::path& filename, TrajectoryInterpolation interpolation, T /*unused*/) { - ifstream in(filename.string()); + ifstream in(filename); if (!in.good()) return nullptr; @@ -828,7 +828,7 @@ template SampledOrbitXYZV* LoadSampledOrbitXYZV(const fs::path& template SampledOrbitXYZV* LoadSampledOrbitXYZVBinary(const fs::path& filename, TrajectoryInterpolation interpolation, T /*unused*/) { - ifstream in(filename.string(), ios::binary); + ifstream in(filename, ios::binary); if (!in.good()) { GetLogger()->error(_("Error opening {}.\n"), filename); diff --git a/src/celephem/samporient.cpp b/src/celephem/samporient.cpp index aedf25137..9aa3b2b36 100644 --- a/src/celephem/samporient.cpp +++ b/src/celephem/samporient.cpp @@ -218,7 +218,7 @@ SampledOrientation::getOrientation(double tjd) const RotationModel* LoadSampledOrientation(const fs::path& filename) { - ifstream in(filename.string()); + ifstream in(filename); if (!in.good()) return nullptr; diff --git a/src/celestia/celestiacore.cpp b/src/celestia/celestiacore.cpp index 8579fce67..4a9201ba5 100644 --- a/src/celestia/celestiacore.cpp +++ b/src/celestia/celestiacore.cpp @@ -236,7 +236,7 @@ void CelestiaCore::readFavoritesFile() path = WriteableDataPath() / path; #endif - ifstream in(path.string(), ios::in); + ifstream in(path, ios::in); if (in.good()) { favorites = ReadFavoritesList(in); @@ -275,7 +275,7 @@ void CelestiaCore::writeFavoritesFile() } } - ofstream out(path.string(), ios::out); + ofstream out(path, ios::out); if (out.good()) WriteFavoritesList(*favorites, out); } @@ -3683,7 +3683,7 @@ class SolarSystemLoader if (notifier != nullptr) notifier->update(filepath.filename().string()); - ifstream solarSysFile(filepath.string(), ios::in); + ifstream solarSysFile(filepath, ios::in); if (solarSysFile.good()) { LoadSolarSystemObjects(solarSysFile, @@ -3729,7 +3729,7 @@ template class CatalogLoader if (notifier != nullptr) notifier->update(filepath.filename().string()); - ifstream catalogFile(filepath.string(), ios::in); + ifstream catalogFile(filepath, ios::in); if (catalogFile.good()) { if (!objDB->load(catalogFile, filepath.parent_path())) @@ -3837,7 +3837,7 @@ bool CelestiaCore::initSimulation(const fs::path& configFileName, if (progressNotifier) progressNotifier->update(file.string()); - ifstream dsoFile(file.string(), ios::in); + ifstream dsoFile(file, ios::in); if (!dsoFile.good()) { GetLogger()->error(_("Error opening deepsky catalog file {}.\n"), file); @@ -3890,7 +3890,7 @@ bool CelestiaCore::initSimulation(const fs::path& configFileName, if (progressNotifier) progressNotifier->update(file.string()); - ifstream solarSysFile(file.string(), ios::in); + ifstream solarSysFile(file, ios::in); if (!solarSysFile.good()) { GetLogger()->error(_("Error opening solar system catalog {}.\n"), file); @@ -3930,7 +3930,7 @@ bool CelestiaCore::initSimulation(const fs::path& configFileName, // Load asterisms: if (!config->asterismsFile.empty()) { - ifstream asterismsFile(config->asterismsFile.string(), ios::in); + ifstream asterismsFile(config->asterismsFile, ios::in); if (!asterismsFile.good()) { GetLogger()->error(_("Error opening asterisms file {}.\n"), @@ -3946,7 +3946,7 @@ bool CelestiaCore::initSimulation(const fs::path& configFileName, if (!config->boundariesFile.empty()) { - ifstream boundariesFile(config->boundariesFile.string(), ios::in); + ifstream boundariesFile(config->boundariesFile, ios::in); if (!boundariesFile.good()) { GetLogger()->error(_("Error opening constellation boundaries file {}.\n"), @@ -3963,7 +3963,7 @@ bool CelestiaCore::initSimulation(const fs::path& configFileName, if (!config->destinationsFile.empty()) { fs::path localeDestinationsFile = LocaleFilename(config->destinationsFile); - ifstream destfile(localeDestinationsFile.string()); + ifstream destfile(localeDestinationsFile, ios::in); if (destfile.good()) { destinations = ReadDestinationList(destfile); @@ -4156,7 +4156,7 @@ static void loadCrossIndex(StarDatabase* starDB, { if (!filename.empty()) { - ifstream xrefFile(filename.string(), ios::in | ios::binary); + ifstream xrefFile(filename, ios::in | ios::binary); if (xrefFile.good()) { if (!starDB->loadCrossIndex(catalog, xrefFile)) @@ -4174,7 +4174,7 @@ bool CelestiaCore::readStars(const CelestiaConfig& cfg, StarDetails::SetStarTextures(cfg.starTextures); StarNameDatabase* starNameDB = nullptr; - ifstream starNamesFile(cfg.starNamesFile.string(), ios::in); + ifstream starNamesFile(cfg.starNamesFile, ios::in); if (starNamesFile.good()) { starNameDB = StarNameDatabase::readNames(starNamesFile); @@ -4194,7 +4194,7 @@ bool CelestiaCore::readStars(const CelestiaConfig& cfg, if (progressNotifier) progressNotifier->update(cfg.starDatabaseFile.string()); - ifstream starFile(cfg.starDatabaseFile.string(), ios::in | ios::binary); + ifstream starFile(cfg.starDatabaseFile, ios::in | ios::binary); if (!starFile.good()) { GetLogger()->error(_("Error opening {}\n"), cfg.starDatabaseFile); @@ -4227,7 +4227,7 @@ bool CelestiaCore::readStars(const CelestiaConfig& cfg, if (file.empty()) continue; - ifstream starFile(file.string(), ios::in); + ifstream starFile(file, ios::in); if (starFile.good()) starDB->load(starFile); else @@ -4880,7 +4880,7 @@ CelestiaCore::TemperatureScale CelestiaCore::getTemperatureScale() const void CelestiaCore::setLogFile(const fs::path &fn) { - m_logfile = std::ofstream(fn.string()); + m_logfile = std::ofstream(fn); if (m_logfile.good()) { m_tee = teestream(m_logfile, *console); diff --git a/src/celestia/configfile.cpp b/src/celestia/configfile.cpp index 50664eab4..0dc97e726 100644 --- a/src/celestia/configfile.cpp +++ b/src/celestia/configfile.cpp @@ -34,7 +34,7 @@ static unsigned int getUint(Hash* params, CelestiaConfig* ReadCelestiaConfig(const fs::path& filename, CelestiaConfig *config) { - ifstream configFile(filename.string()); + ifstream configFile(filename); if (!configFile.good()) { GetLogger()->error("Error opening config file '{}'.\n", filename); diff --git a/src/celestia/qt/qtappwin.cpp b/src/celestia/qt/qtappwin.cpp index b80b46bb0..85539d0ba 100644 --- a/src/celestia/qt/qtappwin.cpp +++ b/src/celestia/qt/qtappwin.cpp @@ -1619,7 +1619,7 @@ QMenu* CelestiaAppWindow::buildScriptsMenu() for (const auto& script : *scripts) { QAction* act = new QAction(script.title.c_str(), this); - act->setData(script.filename.string().c_str()); + act->setData(script.filename.c_str()); connect(act, SIGNAL(triggered()), this, SLOT(slotOpenScript())); menu->addAction(act); } diff --git a/src/celestia/scriptmenu.cpp b/src/celestia/scriptmenu.cpp index 4ad4030fa..90f307746 100644 --- a/src/celestia/scriptmenu.cpp +++ b/src/celestia/scriptmenu.cpp @@ -36,7 +36,7 @@ static void process(const fs::path& p, vector* menuItems) // Scan the script file for metainformation. At the moment, // the only thing searched for is the script title, which must // appear on the first line after the string 'Title:' - ifstream in(p.string()); + ifstream in(p); if (in.good()) { ScriptMenuItem item; diff --git a/src/celestia/win32/winmain.cpp b/src/celestia/win32/winmain.cpp index a605f60ed..aa0ffcf79 100644 --- a/src/celestia/win32/winmain.cpp +++ b/src/celestia/win32/winmain.cpp @@ -499,7 +499,7 @@ bool LoadItemTextFromFile(HWND hWnd, const fs::path& filename) { // ifstream textFile(filename, ios::in | ios::binary); - ifstream textFile(filename.string(), ios::in); + ifstream textFile(filename, ios::in); string s; if (!textFile.good()) diff --git a/src/celimage/dds.cpp b/src/celimage/dds.cpp index 571be296d..8ee6d3ff3 100644 --- a/src/celimage/dds.cpp +++ b/src/celimage/dds.cpp @@ -137,7 +137,7 @@ uint32_t* decompressDXTc(uint32_t width, uint32_t height, GLenum format, bool tr Image* LoadDDSImage(const fs::path& filename) { - ifstream in(filename.string(), ios::in | ios::binary); + ifstream in(filename, ios::in | ios::binary); if (!in.good()) { GetLogger()->error("Error opening DDS texture file {}.\n", filename); diff --git a/src/celscript/legacy/legacyscript.cpp b/src/celscript/legacy/legacyscript.cpp index 8063d094d..b135b5346 100644 --- a/src/celscript/legacy/legacyscript.cpp +++ b/src/celscript/legacy/legacyscript.cpp @@ -88,7 +88,7 @@ bool LegacyScriptPlugin::isOurFile(const fs::path &p) const unique_ptr LegacyScriptPlugin::loadScript(const fs::path &path) { - ifstream scriptfile(path.string()); + ifstream scriptfile(path); if (!scriptfile.good()) { appCore()->fatalError(_("Error opening script file.")); diff --git a/src/celscript/lua/luascript.cpp b/src/celscript/lua/luascript.cpp index 3cbb136c9..39559e50b 100644 --- a/src/celscript/lua/luascript.cpp +++ b/src/celscript/lua/luascript.cpp @@ -84,7 +84,7 @@ bool LuaScriptPlugin::isOurFile(const fs::path &p) const unique_ptr LuaScriptPlugin::loadScript(const fs::path &path) { - ifstream scriptfile(path.string()); + ifstream scriptfile(path); if (!scriptfile.good()) { appCore()->fatalError(fmt::sprintf(_("Error opening script '%s'"), path)); @@ -209,7 +209,7 @@ bool CreateLuaEnvironment(CelestiaCore *appCore, const CelestiaConfig *config, P // Execute the Lua hook initialization script if (!config->luaHook.empty()) { - ifstream scriptfile(config->luaHook.string()); + ifstream scriptfile(config->luaHook); if (!scriptfile.good()) appCore->fatalError(fmt::sprintf(_("Error opening LuaHook '%s'"), config->luaHook));