diff --git a/app/scanner2/mainwindow.cpp b/app/scanner2/mainwindow.cpp index 40725c21..e9e172b2 100644 --- a/app/scanner2/mainwindow.cpp +++ b/app/scanner2/mainwindow.cpp @@ -106,10 +106,6 @@ MainWindow::MainWindow(const QString& appLang, QWidget *parent) m_versionDll = new VersionDll; HGBase_RegisterCrashFunc(CrashFunc, this); - HGChar logFilePath[512]; - HGBase_GetLogFilePath(logFilePath, 512); - deleteOverdueLogFile(QString::fromStdString(getStdString(logFilePath))); - HGChar cfgFilePath[512]; HGBase_GetConfigPath(cfgFilePath, 512); deleteUpgradePkg(QString::fromStdString(getStdString(cfgFilePath))); @@ -2987,7 +2983,7 @@ void HGAPI MainWindow::CrashFunc(HGPointer crashAddr, HGPointer param) HGChar crashName[256]; - HGBase_GetLogFilePath(crashName, 256); + HGBase_GetConfigPath(crashName, 256); strcat(crashName, "crash.dmp"); if (HGBASE_ERR_OK == HGBase_MakeCrashFile(crashName)) { diff --git a/app/scantool/mainwindow.cpp b/app/scantool/mainwindow.cpp index 5e36f845..20c3260a 100644 --- a/app/scantool/mainwindow.cpp +++ b/app/scantool/mainwindow.cpp @@ -1225,7 +1225,7 @@ void MainWindow::ocrMsgPumpFunc(HGMsgPump msgPump, const HGMsg *msg, HGPointer p void MainWindow::CrashFunc(HGPointer crashAddr, HGPointer param) { HGChar crashName[256]; - HGBase_GetLogFilePath(crashName, 256); + HGBase_GetConfigPath(crashName, 256); strcat(crashName, "crash.dmp"); if (HGBASE_ERR_OK == HGBase_MakeCrashFile(crashName)) { diff --git a/build2/qt/HGBase/HGBase.def b/build2/qt/HGBase/HGBase.def index 6f3c282f..bc88d0d2 100644 --- a/build2/qt/HGBase/HGBase.def +++ b/build2/qt/HGBase/HGBase.def @@ -56,7 +56,7 @@ HGBase_GetModuleName HGBase_GetUuid HGBase_GetTmpFileName HGBase_GetConfigPath -HGBase_GetLogFilePath +HGBase_GetCacheFilePath HGBase_GetDocumentsPath HGBase_GetProcessName HGBase_GetFilePath diff --git a/modules/base/HGUtility.cpp b/modules/base/HGUtility.cpp index 7421c7eb..3ab99319 100644 --- a/modules/base/HGUtility.cpp +++ b/modules/base/HGUtility.cpp @@ -273,32 +273,6 @@ HGResult HGAPI HGBase_GetConfigPath(HGChar* configPath, HGUInt maxLen) return HGBASE_ERR_INVALIDARG; } - HGChar moduleName[256]; - HGBase_GetModuleName(NULL, moduleName, 256); - HGChar modulePath[256]; - HGBase_GetFilePath(moduleName, modulePath, 256); - strcat(modulePath, "first.cfg"); - - HGChar dataPath[256] = {0}; - HGBase_GetProfileString(modulePath, "constraints", "local_data_path", "", dataPath, 256); - if ('\0' != *dataPath) - { -#if defined(HG_CMP_MSC) - if (dataPath[strlen(dataPath) - 1] != '\\') - strcat(dataPath, "\\"); - strcat(dataPath, "Cfg\\"); -#else - if (dataPath[strlen(dataPath) - 1] != '/') - strcat(dataPath, "/"); - strcat(dataPath, "Cfg/"); -#endif - - if (maxLen < strlen(dataPath) + 1) - return HGBASE_ERR_FAIL; - strcpy(configPath, dataPath); - return HGBASE_ERR_OK; - } - #if defined(HG_CMP_MSC) CHAR cfgPath[MAX_PATH] = { 0 }; BOOL ret = SHGetSpecialFolderPathA(NULL, cfgPath, CSIDL_APPDATA, FALSE); @@ -331,69 +305,43 @@ HGResult HGAPI HGBase_GetConfigPath(HGChar* configPath, HGUInt maxLen) return HGBASE_ERR_OK; } -HGResult HGAPI HGBase_GetLogFilePath(HGChar* logFilePath, HGUInt maxLen) +HGResult HGAPI HGBase_GetCacheFilePath(HGChar* cacheFilePath, HGUInt maxLen) { - if (NULL == logFilePath || 0 == maxLen) - { - return HGBASE_ERR_INVALIDARG; - } - - HGChar moduleName[256]; - HGBase_GetModuleName(NULL, moduleName, 256); - HGChar modulePath[256]; - HGBase_GetFilePath(moduleName, modulePath, 256); - strcat(modulePath, "first.cfg"); - - HGChar dataPath[256] = { 0 }; - HGBase_GetProfileString(modulePath, "constraints", "local_data_path", "", dataPath, 256); - if ('\0' != *dataPath) - { -#if defined(HG_CMP_MSC) - if (dataPath[strlen(dataPath) - 1] != '\\') - strcat(dataPath, "\\"); - strcat(dataPath, "Cfg\\"); -#else - if (dataPath[strlen(dataPath) - 1] != '/') - strcat(dataPath, "/"); - strcat(dataPath, "Cfg/"); -#endif - - if (maxLen < strlen(dataPath) + 1) - return HGBASE_ERR_FAIL; - strcpy(logFilePath, dataPath); - return HGBASE_ERR_OK; - } + if (NULL == cacheFilePath || 0 == maxLen) + { + return HGBASE_ERR_INVALIDARG; + } #if defined(HG_CMP_MSC) - CHAR logPath[MAX_PATH] = { 0 }; - BOOL ret = SHGetSpecialFolderPathA(NULL, logPath, CSIDL_APPDATA, FALSE); - if (!ret) - return HGBASE_ERR_FAIL; - if (logPath[strlen(logPath) - 1] != '\\') - strcat(logPath, "\\"); + CHAR cachePath[MAX_PATH] = { 0 }; + BOOL ret = SHGetSpecialFolderPathA(NULL, cachePath, CSIDL_APPDATA, FALSE); + if (!ret) + return HGBASE_ERR_FAIL; + if (cachePath[strlen(cachePath) - 1] != '\\') + strcat(cachePath, "\\"); - HGChar procName[64]; - HGBase_GetProcessName(procName, 64); - strcat(logPath, procName); - strcat(logPath, "\\Log\\"); + HGChar procName[64]; + HGBase_GetProcessName(procName, 64); + strcat(cachePath, procName); + strcat(cachePath, "\\Cache\\"); #else - char logPath[512] = { 0 }; - struct passwd* pw = getpwuid(getuid()); - strcpy(logPath, pw->pw_dir); - if (logPath[strlen(logPath) - 1] != '/') - strcat(logPath, "/"); + char cachePath[512] = { 0 }; + struct passwd* pw = getpwuid(getuid()); + strcpy(cachePath, pw->pw_dir); + if (cachePath[strlen(cachePath) - 1] != '/') + strcat(cachePath, "/"); - strcat(logPath, "."); - HGChar procName[64]; - HGBase_GetProcessName(procName, 64); - strcat(logPath, procName); - strcat(logPath, "/Log/"); + strcat(cachePath, "."); + HGChar procName[64]; + HGBase_GetProcessName(procName, 64); + strcat(cachePath, procName); + strcat(cachePath, "/Cache/"); #endif - if (maxLen < strlen(logPath) + 1) - return HGBASE_ERR_FAIL; - strcpy(logFilePath, logPath); - return HGBASE_ERR_OK; + if (maxLen < strlen(cachePath) + 1) + return HGBASE_ERR_FAIL; + strcpy(cacheFilePath, cachePath); + return HGBASE_ERR_OK; } HGResult HGAPI HGBase_GetDocumentsPath(HGChar* documentsPath, HGUInt maxLen) diff --git a/modules/base/HGUtility.h b/modules/base/HGUtility.h index aa388e39..560469f4 100644 --- a/modules/base/HGUtility.h +++ b/modules/base/HGUtility.h @@ -46,9 +46,9 @@ HGEXPORT HGResult HGAPI HGBase_GetTmpFileName(const HGChar *suffix, HGChar* file */ HGEXPORT HGResult HGAPI HGBase_GetConfigPath(HGChar* configPath, HGUInt maxLen); -/* 获取日志文件路径 +/* 获取缓存文件路径 */ -HGEXPORT HGResult HGAPI HGBase_GetLogFilePath(HGChar* logFilePath, HGUInt maxLen); +HGEXPORT HGResult HGAPI HGBase_GetCacheFilePath(HGChar* cacheFilePath, HGUInt maxLen); /* 获取文档路径 */ @@ -77,4 +77,4 @@ HGEXPORT HGResult HGAPI HGBase_GetFileSuffix(const HGChar *fileName, HGChar* suf /* 将文件名标准化 */ HGEXPORT HGResult HGAPI HGBase_StandardiseFileName(const HGChar* fileName, HGChar *result, HGUInt maxLen); -#endif /* __HGUTILITY_H__ */ \ No newline at end of file +#endif /* __HGUTILITY_H__ */ diff --git a/sdk/webservice/ManagerV1.cpp b/sdk/webservice/ManagerV1.cpp index 888a378c..20f58336 100644 --- a/sdk/webservice/ManagerV1.cpp +++ b/sdk/webservice/ManagerV1.cpp @@ -1388,12 +1388,10 @@ namespace ver_1 std::string ManagerV1::GetFilePath(const std::string& devId) { HGChar docsPath[256]; - HGBase_GetDocumentsPath(docsPath, 256); - HGChar procName[256]; - HGBase_GetProcessName(procName, 256); + HGBase_GetCacheFilePath(docsPath, 256); HGChar imgPath[512]; - sprintf(imgPath, "%s%s/%s/", docsPath, procName, Utf8ToStdString(devId).c_str()); + sprintf(imgPath, "%s%s/", docsPath, Utf8ToStdString(devId).c_str()); HGChar stdImgPath[512]; HGBase_StandardiseFileName(imgPath, stdImgPath, 512); diff --git a/sdk/webservice/ManagerV2.cpp b/sdk/webservice/ManagerV2.cpp index 9c056e66..c8c964d3 100644 --- a/sdk/webservice/ManagerV2.cpp +++ b/sdk/webservice/ManagerV2.cpp @@ -34,12 +34,8 @@ namespace ver_2 m_lock = NULL; HGBase_CreateLock(&m_lock); - HGChar docsPath[256]; - HGBase_GetDocumentsPath(docsPath, 256); - HGChar procName[256]; - HGBase_GetProcessName(procName, 256); - HGChar defSavePath[256]; - sprintf(defSavePath, "%s%s/", docsPath, procName); + HGChar defSavePath[256]; + HGBase_GetCacheFilePath(defSavePath, 256); m_globalCfg.fileSavePath = GetCfgStringValue("global", "fileSavePath", defSavePath); m_globalCfg.fileNamePrefix = GetCfgStringValue("global", "fileNamePrefix", ""); diff --git a/sdk/webservice/main.cpp b/sdk/webservice/main.cpp index caca92e9..7184a237 100644 --- a/sdk/webservice/main.cpp +++ b/sdk/webservice/main.cpp @@ -43,7 +43,7 @@ HGMsgPump msgPumpV2 = NULL; static void HGAPI CrashFunc(HGPointer crashAddr, HGPointer param) { HGChar logPath[256]; - HGBase_GetLogFilePath(logPath, 256); + HGBase_GetConfigPath(logPath, 256); strcat(logPath, "crash.dmp"); HGBase_MakeCrashFile(logPath); }