fix: save history file on windows

This commit is contained in:
hakan-demirli 2024-01-31 20:14:32 +03:00
parent 820232eaca
commit dd5dc06863
1 changed files with 21 additions and 13 deletions

View File

@ -245,6 +245,13 @@ int main(int argc, char **argv)
#if defined(YOSYS_ENABLE_READLINE) || defined(YOSYS_ENABLE_EDITLINE)
std::string state_dir;
#if defined(_WIN32)
if (getenv("HOMEDRIVE") != NULL && getenv("HOMEPATH") != NULL) {
state_dir = stringf("%s%s/.local/state", getenv("HOMEDRIVE"), getenv("HOMEPATH"));
} else {
log("$HOMEDRIVE and/or $HOMEPATH is empty. No history file will be created.");
}
#else
if (getenv("XDG_STATE_HOME") == NULL || getenv("XDG_STATE_HOME")[0] == '\0') {
if (getenv("HOME") != NULL) {
state_dir = stringf("%s/.local/state", getenv("HOME"));
@ -254,6 +261,7 @@ int main(int argc, char **argv)
} else {
state_dir = stringf("%s", getenv("XDG_STATE_HOME"));
}
#endif
if (!state_dir.empty()) {
std::string yosys_dir = state_dir + "/yosys";