mirror of
https://github.com/obsqrbtz/clrsync.git
synced 2026-04-08 20:19:04 +03:00
create windows installed with nsis
This commit is contained in:
@@ -5,6 +5,10 @@
|
||||
#include <filesystem>
|
||||
#include <stdexcept>
|
||||
|
||||
#ifdef _WIN32
|
||||
#include "windows.h"
|
||||
#endif
|
||||
|
||||
namespace clrsync::core
|
||||
{
|
||||
config &config::instance()
|
||||
@@ -33,10 +37,22 @@ std::filesystem::path config::get_user_config_dir()
|
||||
#endif
|
||||
}
|
||||
|
||||
std::filesystem::path config::get_data_dir() {
|
||||
#ifdef _WIN32
|
||||
char buffer[MAX_PATH];
|
||||
GetModuleFileNameA(nullptr, buffer, MAX_PATH);
|
||||
std::filesystem::path exe_path(buffer);
|
||||
std::filesystem::path data_dir = exe_path.parent_path().parent_path() / "share" / "clrsync";
|
||||
return data_dir;
|
||||
#else
|
||||
return {CLRSYNC_DATADIR};
|
||||
#endif
|
||||
}
|
||||
|
||||
void config::copy_default_configs()
|
||||
{
|
||||
std::filesystem::path user_config = get_user_config_dir();
|
||||
std::filesystem::path default_dir = CLRSYNC_DATADIR;
|
||||
std::filesystem::path default_dir = get_data_dir();
|
||||
|
||||
if (!std::filesystem::exists(user_config))
|
||||
{
|
||||
|
||||
@@ -32,6 +32,7 @@ class config
|
||||
|
||||
void update_template(const std::string &key,
|
||||
const clrsync::core::theme_template &theme_template);
|
||||
static std::filesystem::path get_data_dir();
|
||||
|
||||
private:
|
||||
config() = default;
|
||||
|
||||
@@ -28,7 +28,7 @@ void palette_controller::select_palette(const std::string& name)
|
||||
|
||||
void palette_controller::create_palette(const std::string& name)
|
||||
{
|
||||
clrsync::core::palette new_palette = m_palette_manager.load_palette_from_file(std::string(CLRSYNC_DATADIR) + "/palettes/cursed.toml");
|
||||
clrsync::core::palette new_palette = m_palette_manager.load_palette_from_file(clrsync::core::config::get_data_dir().string() + "/palettes/cursed.toml");
|
||||
new_palette.set_name(name);
|
||||
|
||||
auto dir = clrsync::core::config::instance().palettes_path();
|
||||
|
||||
Reference in New Issue
Block a user