Skip to content

Commit 012251f

Browse files
committed
filesystem fixes
1 parent 61b860f commit 012251f

File tree

2 files changed

+7
-6
lines changed

2 files changed

+7
-6
lines changed

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ In most cases, you can also type `\n` to go to a new line
3232

3333
General syntax for ALL FILES is:
3434

35-
```json
35+
```jsonc
3636
{
3737
"to-show": "name", // spawned when pressing hotkey
3838
"to-show-alt": "alt-name", // spawned when holding alt and pressing hotkey

src/main.cpp

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -25,9 +25,11 @@ std::string altShowKey = "to-show-alt";
2525
// Create files if they don't exist
2626
void checkMissingFiles() {
2727
Mod::get()->getConfigDir(); // create config folder if missing
28-
if (!fs::exists(CustomAlert::jsonFilePath)) fs::copy_file(Mod::get()->getResourcesDir() / CustomAlert::jsonFileName, CustomAlert::jsonFilePath);
29-
if (!fs::exists(CustomTextbox::jsonFilePath)) fs::copy_file(Mod::get()->getResourcesDir() / CustomTextbox::jsonFileName, CustomTextbox::jsonFilePath);
30-
if (!fs::exists(CustomChest::jsonFilePath)) fs::copy_file(Mod::get()->getResourcesDir() / CustomChest::jsonFileName, CustomChest::jsonFilePath);
28+
std::error_code ec;
29+
if (!fs::exists(CustomAlert::jsonFilePath)) fs::copy_file(Mod::get()->getResourcesDir() / CustomAlert::jsonFileName, CustomAlert::jsonFilePath, ec);
30+
if (!fs::exists(CustomTextbox::jsonFilePath)) fs::copy_file(Mod::get()->getResourcesDir() / CustomTextbox::jsonFileName, CustomTextbox::jsonFilePath, ec);
31+
if (!fs::exists(CustomChest::jsonFilePath)) fs::copy_file(Mod::get()->getResourcesDir() / CustomChest::jsonFileName, CustomChest::jsonFilePath, ec);
32+
if (ec) { log::error("Filesystem error: {}", ec.message()); }
3133
}
3234

3335
void clearQueue() {
@@ -177,7 +179,6 @@ class $modify(CCKeyboardDispatcher) {
177179
}
178180
};
179181

180-
181-
$execute {
182+
$on_mod(Loaded) {
182183
checkMissingFiles();
183184
}

0 commit comments

Comments
 (0)