Skip to content

Commit 78111e3

Browse files
committed
Fix automatic creation of configuration directory.
1 parent 3b46415 commit 78111e3

File tree

1 file changed

+9
-0
lines changed

1 file changed

+9
-0
lines changed

src/rc.c

+9
Original file line numberDiff line numberDiff line change
@@ -1136,11 +1136,20 @@ void save_config(Theme *theme, Game *game) {
11361136
}
11371137
fclose(f);
11381138
} else {
1139+
char *user_rc_dir, *temp;
11391140
char *system_rc_path = find_system_config_file("csolrc");
11401141
if (!system_rc_path) {
11411142
print_error("Error: No system configuration file found");
11421143
return;
11431144
}
1145+
temp = strdup(user_rc_path);
1146+
user_rc_dir = dirname(temp);
1147+
if (!mkdir_rec(user_rc_dir)) {
1148+
print_error("Error: Unable to create configuration directory: %s: %s", user_rc_dir, strerror(errno));
1149+
free(temp);
1150+
return;
1151+
}
1152+
free(temp);
11441153
f = fopen(user_rc_path, "wb");
11451154
if (!f) {
11461155
print_error("Error: Unable to create configuration file: %s: %s", user_rc_path, strerror(errno));

0 commit comments

Comments
 (0)