From 268fe4ba733c4739f1853ba050db993d8757f0fc Mon Sep 17 00:00:00 2001 From: dongwlin Date: Sun, 19 Nov 2023 13:23:09 +0800 Subject: [PATCH] feat: config existence check --- source/cli/Config/Config.cpp | 5 +++++ source/cli/Config/Config.h | 1 + 2 files changed, 6 insertions(+) diff --git a/source/cli/Config/Config.cpp b/source/cli/Config/Config.cpp index 2a32bd6..9375d76 100644 --- a/source/cli/Config/Config.cpp +++ b/source/cli/Config/Config.cpp @@ -1,5 +1,10 @@ #include "Config.h" +bool Config::exists() +{ + return std::filesystem::exists(_target_path); +} + bool Config::load() { auto config_opt = json::open(_target_path); diff --git a/source/cli/Config/Config.h b/source/cli/Config/Config.h index 4db5001..568e31b 100644 --- a/source/cli/Config/Config.h +++ b/source/cli/Config/Config.h @@ -12,6 +12,7 @@ class Config virtual ~Config() = default; public: + virtual bool exists(); virtual bool parse(const json::value& config_json) = 0; virtual bool load(); virtual json::value to_json() = 0;