Mercurial > minori
diff src/core/config.cpp @ 61:327568ad9be9
core/fs: finish class-ification of paths
author | Paper <mrpapersonic@gmail.com> |
---|---|
date | Fri, 29 Sep 2023 15:52:31 -0400 |
parents | cde8f67a7c7d |
children | 6f7385bd334c |
line wrap: on
line diff
--- a/src/core/config.cpp Fri Sep 29 13:52:50 2023 -0400 +++ b/src/core/config.cpp Fri Sep 29 15:52:31 2023 -0400 @@ -47,10 +47,10 @@ }; int Config::Load() { - std::string cfg_path = Filesystem::GetConfigPath(); - if (!Filesystem::Exists(cfg_path)) + Filesystem::Path cfg_path = Filesystem::GetConfigPath(); + if (!cfg_path.Exists()) return 0; - std::ifstream config(cfg_path.c_str(), std::ifstream::in); + std::ifstream config(cfg_path.GetPath(), std::ifstream::in); auto config_js = nlohmann::json::parse(config); service = StringToService[JSON::GetString(config_js, "/General/Service"_json_pointer)]; anime_list.language = StringToAnimeTitleMap[JSON::GetString( @@ -72,10 +72,10 @@ } int Config::Save() { - std::string cfg_path = Filesystem::GetConfigPath(); - if (!Filesystem::Exists(Filesystem::GetParentDirectory(cfg_path))) - Filesystem::CreateDirectories(Filesystem::GetParentDirectory(cfg_path)); - std::ofstream config(cfg_path.c_str(), std::ofstream::out | std::ofstream::trunc); + Filesystem::Path cfg_path = Filesystem::GetConfigPath(); + if (!cfg_path.GetParent().Exists()) + cfg_path.GetParent().CreateDirectories(); + std::ofstream config(cfg_path.GetPath(), std::ofstream::out | std::ofstream::trunc); // clang-format off nlohmann::json config_js = { {"General", {