From 0171e93cea4d58998791e219c281489620586759 Mon Sep 17 00:00:00 2001 From: gb <741021719@qq.com> Date: Tue, 5 Jul 2022 17:54:59 +0800 Subject: [PATCH] =?UTF-8?q?=E9=92=88=E5=AF=B9=E7=89=B9=E6=AE=8A=E7=B3=BB?= =?UTF-8?q?=E7=BB=9F=EF=BC=8C=E5=A2=9E=E5=8A=A0first.cfg=E9=85=8D=E7=BD=AE?= =?UTF-8?q?=E6=96=87=E4=BB=B6=EF=BC=8C=E5=AD=98=E5=82=A8=E9=99=90=E5=88=B6?= =?UTF-8?q?=E5=86=85=E5=AE=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- hgdriver/hgdev/hg_scanner.cpp | 2 ++ hgdriver/wrapper/hg_log.cpp | 39 ++++++++++++++++++++++++++++------- 2 files changed, 33 insertions(+), 8 deletions(-) diff --git a/hgdriver/hgdev/hg_scanner.cpp b/hgdriver/hgdev/hg_scanner.cpp index e8200c7..587278c 100644 --- a/hgdriver/hgdev/hg_scanner.cpp +++ b/hgdriver/hgdev/hg_scanner.cpp @@ -2506,6 +2506,8 @@ int hg_scanner::device_io_control(unsigned long code, void* data, unsigned* len) SANE_Gamma* v = (SANE_Gamma*)data; memcpy(v, custom_gamma_val_, sizeof(*custom_gamma_val_)); + if (len) + *len = image_prc_param_.bits.color_mode; return SCANNER_ERR_OK; } diff --git a/hgdriver/wrapper/hg_log.cpp b/hgdriver/wrapper/hg_log.cpp index 5ef53ef..10bb5dd 100644 --- a/hgdriver/wrapper/hg_log.cpp +++ b/hgdriver/wrapper/hg_log.cpp @@ -506,15 +506,38 @@ extern "C" } std::string local_data_path(void) { -#ifdef WIN32 - std::string env("LOCALAPPDATA"), lead(""); -#else - std::string env("HOME"), lead("."); -#endif - char* tmp = getenv(env.c_str()); - std::string home(tmp ? tmp : ""); + static std::string local_data_path(""); + static bool load_first = true; - home += PATH_SEPARATOR + lead; + if (load_first) + { + simple_ini first; + + load_first = false; + if (first.load((get_scanner_path() + "first.cfg").c_str()) == 0) + { + std::string env = first.get("constraints", "local_data_path"); + if (env.length()) + local_data_path = env; + } + } + + std::string home(local_data_path); + + if (home.empty()) + { +#ifdef WIN32 + std::string env("LOCALAPPDATA"), lead(""); +#else + std::string env("HOME"), lead("."); +#endif + char* tmp = getenv(env.c_str()); + + if (tmp) + home = tmp; + + home += PATH_SEPARATOR + lead; + } #ifdef OEM_HANWANG home += "HanvonScan";