mirror of
https://github.com/Dushistov/sdcv.git
synced 2025-12-15 17:31:56 +00:00
Keep searching in $HOME
This commit is contained in:
@@ -68,8 +68,12 @@ std::string get_hist_file_path()
|
|||||||
|
|
||||||
if (hist_file_str != nullptr)
|
if (hist_file_str != nullptr)
|
||||||
return std::string(hist_file_str);
|
return std::string(hist_file_str);
|
||||||
else
|
|
||||||
return std::string(g_get_user_data_dir()) + G_DIR_SEPARATOR + "sdcv_history";
|
const std::string hist_file_path = std::string(g_get_home_dir()) + G_DIR_SEPARATOR + ".sdcv_history";
|
||||||
|
if (g_file_test(hist_file_path.c_str(), G_FILE_TEST_IS_REGULAR))
|
||||||
|
return hist_file_path;
|
||||||
|
|
||||||
|
return std::string(g_get_user_data_dir()) + G_DIR_SEPARATOR + "sdcv_history";
|
||||||
}
|
}
|
||||||
|
|
||||||
class real_readline : public IReadLine
|
class real_readline : public IReadLine
|
||||||
|
|||||||
15
src/sdcv.cpp
15
src/sdcv.cpp
@@ -141,9 +141,13 @@ int main(int argc, char *argv[]) try {
|
|||||||
data_dir = get_impl(opt_data_dir);
|
data_dir = get_impl(opt_data_dir);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
std::string conf_dir = std::string(g_get_home_dir()) + G_DIR_SEPARATOR + ".stardict";
|
||||||
|
if (!g_file_test(conf_dir.c_str(), G_FILE_TEST_IS_DIR))
|
||||||
|
conf_dir = std::string(g_get_user_data_dir()) + G_DIR_SEPARATOR + "stardict";
|
||||||
|
|
||||||
std::list<std::string> dicts_dir_list;
|
std::list<std::string> dicts_dir_list;
|
||||||
if (!only_data_dir)
|
if (!only_data_dir)
|
||||||
dicts_dir_list.push_back(std::string(g_get_user_data_dir()) + G_DIR_SEPARATOR + "stardict" + G_DIR_SEPARATOR + "dic");
|
dicts_dir_list.push_back(conf_dir + G_DIR_SEPARATOR + "dic");
|
||||||
dicts_dir_list.push_back(data_dir);
|
dicts_dir_list.push_back(data_dir);
|
||||||
if (show_list_dicts) {
|
if (show_list_dicts) {
|
||||||
list_dicts(dicts_dir_list, json_output);
|
list_dicts(dicts_dir_list, json_output);
|
||||||
@@ -182,8 +186,12 @@ int main(int argc, char *argv[]) try {
|
|||||||
++p;
|
++p;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
const std::string odering_cfg_file = std::string(g_get_user_config_dir()) + G_DIR_SEPARATOR_S "sdcv_ordering";
|
std::string ordering_cfg_file = std::string(g_get_user_config_dir()) + G_DIR_SEPARATOR_S "sdcv_ordering";
|
||||||
FILE *ordering_file = fopen(odering_cfg_file.c_str(), "r");
|
FILE *ordering_file = fopen(ordering_cfg_file.c_str(), "r");
|
||||||
|
if (ordering_file == nullptr) {
|
||||||
|
ordering_cfg_file = std::string(g_get_home_dir()) + G_DIR_SEPARATOR_S ".sdcv_ordering";
|
||||||
|
ordering_file = fopen(ordering_cfg_file.c_str(), "r");
|
||||||
|
}
|
||||||
if (ordering_file != nullptr) {
|
if (ordering_file != nullptr) {
|
||||||
std::string line;
|
std::string line;
|
||||||
while (stdio_getline(ordering_file, line)) {
|
while (stdio_getline(ordering_file, line)) {
|
||||||
@@ -193,7 +201,6 @@ int main(int argc, char *argv[]) try {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
const std::string conf_dir = std::string(g_get_user_data_dir()) + G_DIR_SEPARATOR + "stardict";
|
|
||||||
if (g_mkdir(conf_dir.c_str(), S_IRWXU) == -1 && errno != EEXIST) {
|
if (g_mkdir(conf_dir.c_str(), S_IRWXU) == -1 && errno != EEXIST) {
|
||||||
fprintf(stderr, _("g_mkdir failed: %s\n"), strerror(errno));
|
fprintf(stderr, _("g_mkdir failed: %s\n"), strerror(errno));
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user