调整WIN平台获取本地数据路径方式

This commit is contained in:
gb 2022-06-06 14:27:42 +08:00
parent 5943ee86d6
commit 3dce0bf435
1 changed files with 9 additions and 15 deletions

View File

@ -463,9 +463,9 @@ extern "C"
return ps; return ps;
} }
static int get_log_config(const std::string& self_path, hg_log_type* type, std::string* path) static int get_log_config(const std::string& root, hg_log_type* type, std::string* path)
{ {
std::string me(self_path + PATH_SEPARATOR + "Cfg" + PATH_SEPARATOR + " scanner.conf"); std::string me(root + PATH_SEPARATOR + "Cfg" + PATH_SEPARATOR + " scanner.conf");
int lv = LOG_LEVEL_ALL; int lv = LOG_LEVEL_ALL;
hg_log_type tp = LOG_TYPE_FILE; hg_log_type tp = LOG_TYPE_FILE;
@ -496,27 +496,21 @@ extern "C"
lv = LOG_LEVEL_FATAL; lv = LOG_LEVEL_FATAL;
} }
else else
create_folder((self_path + PATH_SEPARATOR + "Cfg").c_str()); create_folder((root + PATH_SEPARATOR + "Cfg").c_str());
return lv; return lv;
} }
std::string local_data_path(void) std::string local_data_path(void)
{ {
#ifdef WIN32 #ifdef WIN32
char* tmp = getenv("TMP"); std::string env("LOCALAPPDATA"), lead("");
std::string home(tmp ? tmp : "");
if (home.length())
{
size_t pos = home.rfind('\\');
if (pos++ != std::string::npos)
home.erase(pos);
}
#else #else
std::string home(getenv("HOME")); std::string env("HOME"), lead(".");
home += "/.";
#endif #endif
char* tmp = getenv(env.c_str());
std::string home(tmp ? tmp : "");
home += PATH_SEPARATOR + lead;
#ifdef OEM_HANWANG #ifdef OEM_HANWANG
home += "HwScanner"; home += "HwScanner";