mirror of
https://github.com/hyprwm/Hyprland
synced 2024-12-25 18:49:47 +01:00
ensure state store always exists
This commit is contained in:
parent
e13cc2e71b
commit
02eae0a107
2 changed files with 25 additions and 0 deletions
|
@ -4,7 +4,21 @@
|
||||||
#include <filesystem>
|
#include <filesystem>
|
||||||
#include <fstream>
|
#include <fstream>
|
||||||
|
|
||||||
|
void DataState::ensureStateStoreExists() {
|
||||||
|
const auto HOME = getenv("HOME");
|
||||||
|
if (!HOME) {
|
||||||
|
std::cerr << "DataState: no $HOME\n";
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
const auto PATH = std::string(HOME) + "/.hyprpm/";
|
||||||
|
|
||||||
|
if (!std::filesystem::exists(PATH))
|
||||||
|
std::filesystem::create_directories(PATH);
|
||||||
|
}
|
||||||
|
|
||||||
void DataState::addNewPluginRepo(const SPluginRepository& repo) {
|
void DataState::addNewPluginRepo(const SPluginRepository& repo) {
|
||||||
|
ensureStateStoreExists();
|
||||||
|
|
||||||
const auto HOME = getenv("HOME");
|
const auto HOME = getenv("HOME");
|
||||||
if (!HOME) {
|
if (!HOME) {
|
||||||
std::cerr << "DataState: no $HOME\n";
|
std::cerr << "DataState: no $HOME\n";
|
||||||
|
@ -38,6 +52,8 @@ void DataState::addNewPluginRepo(const SPluginRepository& repo) {
|
||||||
}
|
}
|
||||||
|
|
||||||
bool DataState::pluginRepoExists(const std::string& urlOrName) {
|
bool DataState::pluginRepoExists(const std::string& urlOrName) {
|
||||||
|
ensureStateStoreExists();
|
||||||
|
|
||||||
const auto HOME = getenv("HOME");
|
const auto HOME = getenv("HOME");
|
||||||
if (!HOME) {
|
if (!HOME) {
|
||||||
std::cerr << "DataState: no $HOME\n";
|
std::cerr << "DataState: no $HOME\n";
|
||||||
|
@ -62,6 +78,8 @@ bool DataState::pluginRepoExists(const std::string& urlOrName) {
|
||||||
}
|
}
|
||||||
|
|
||||||
void DataState::removePluginRepo(const std::string& urlOrName) {
|
void DataState::removePluginRepo(const std::string& urlOrName) {
|
||||||
|
ensureStateStoreExists();
|
||||||
|
|
||||||
const auto HOME = getenv("HOME");
|
const auto HOME = getenv("HOME");
|
||||||
if (!HOME) {
|
if (!HOME) {
|
||||||
std::cerr << "DataState: no $HOME\n";
|
std::cerr << "DataState: no $HOME\n";
|
||||||
|
@ -86,6 +104,8 @@ void DataState::removePluginRepo(const std::string& urlOrName) {
|
||||||
}
|
}
|
||||||
|
|
||||||
void DataState::updateGlobalState(const SGlobalState& state) {
|
void DataState::updateGlobalState(const SGlobalState& state) {
|
||||||
|
ensureStateStoreExists();
|
||||||
|
|
||||||
const auto HOME = getenv("HOME");
|
const auto HOME = getenv("HOME");
|
||||||
if (!HOME) {
|
if (!HOME) {
|
||||||
std::cerr << "DataState: no $HOME\n";
|
std::cerr << "DataState: no $HOME\n";
|
||||||
|
@ -108,6 +128,8 @@ void DataState::updateGlobalState(const SGlobalState& state) {
|
||||||
}
|
}
|
||||||
|
|
||||||
std::vector<SPluginRepository> DataState::getAllRepositories() {
|
std::vector<SPluginRepository> DataState::getAllRepositories() {
|
||||||
|
ensureStateStoreExists();
|
||||||
|
|
||||||
const auto HOME = getenv("HOME");
|
const auto HOME = getenv("HOME");
|
||||||
if (!HOME) {
|
if (!HOME) {
|
||||||
std::cerr << "DataState: no $HOME\n";
|
std::cerr << "DataState: no $HOME\n";
|
||||||
|
@ -149,6 +171,8 @@ std::vector<SPluginRepository> DataState::getAllRepositories() {
|
||||||
}
|
}
|
||||||
|
|
||||||
bool DataState::setPluginEnabled(const std::string& name, bool enabled) {
|
bool DataState::setPluginEnabled(const std::string& name, bool enabled) {
|
||||||
|
ensureStateStoreExists();
|
||||||
|
|
||||||
const auto HOME = getenv("HOME");
|
const auto HOME = getenv("HOME");
|
||||||
if (!HOME) {
|
if (!HOME) {
|
||||||
std::cerr << "DataState: no $HOME\n";
|
std::cerr << "DataState: no $HOME\n";
|
||||||
|
|
|
@ -8,6 +8,7 @@ struct SGlobalState {
|
||||||
};
|
};
|
||||||
|
|
||||||
namespace DataState {
|
namespace DataState {
|
||||||
|
void ensureStateStoreExists();
|
||||||
void addNewPluginRepo(const SPluginRepository& repo);
|
void addNewPluginRepo(const SPluginRepository& repo);
|
||||||
void removePluginRepo(const std::string& urlOrName);
|
void removePluginRepo(const std::string& urlOrName);
|
||||||
bool pluginRepoExists(const std::string& urlOrName);
|
bool pluginRepoExists(const std::string& urlOrName);
|
||||||
|
|
Loading…
Reference in a new issue