This commit is contained in:
gb 2022-07-06 17:56:49 +08:00
commit e277ae6849
5 changed files with 80 additions and 11 deletions

View File

@ -164,18 +164,20 @@ SOURCES += \
../../../app/upgrade/HGUpgrade.cpp \
../../../app/upgrade/main.cpp \
../../../app/upgrade/mainwindow.cpp \
../../../modules/base/HGIni.cpp \
../../../modules/base/HGMd5.cpp \
../../../modules/base/HGUtility.cpp \
../../../modules/base/HGThread.cpp \
../../../utility/HGString.cpp
../../../utility/HGString.cpp \
HEADERS += \
../../../app/upgrade/HGUpgrade.h \
../../../app/upgrade/mainwindow.h \
../../../modules/base/HGIni.h \
../../../modules/base/HGMd5.h \
../../../modules/base/HGUtility.h \
../../../modules/base/HGThread.h \
../../../utility/HGString.h
../../../utility/HGString.h \
FORMS += \
../../../app/upgrade/mainwindow.ui

View File

@ -168,6 +168,8 @@
<Add option="-z defs" />
<Add option="-B direct" />
</Linker>
<Unit filename="../../../modules/base/HGIni.cpp" />
<Unit filename="../../../modules/base/HGIni.h" />
<Unit filename="../../../modules/base/HGUtility.cpp" />
<Unit filename="../../../modules/base/HGUtility.h" />
<Unit filename="../../../sdk/upload/main.cpp" />

View File

@ -19,11 +19,13 @@
</ProjectConfiguration>
</ItemGroup>
<ItemGroup>
<ClCompile Include="..\..\..\modules\base\HGIni.cpp" />
<ClCompile Include="..\..\..\modules\base\HGUtility.cpp" />
<ClCompile Include="..\..\..\sdk\upload\main.cpp" />
<ClCompile Include="..\..\..\third_party\cgic\cgic.c" />
</ItemGroup>
<ItemGroup>
<ClInclude Include="..\..\..\modules\base\HGIni.h" />
<ClInclude Include="..\..\..\modules\base\HGUtility.h" />
<ClInclude Include="..\..\..\third_party\cgic\cgic.h" />
</ItemGroup>

View File

@ -1,5 +1,6 @@
#include "HGUtility.h"
#include "HGInc.h"
#include "HGIni.h"
#if defined(HG_CMP_MSC)
#include <shlobj.h>
#include <atlstr.h>
@ -170,18 +171,28 @@ HGResult HGAPI HGBase_GetModuleName(HGPointer addr, HGChar* name, HGUInt maxLen)
}
#if !defined(HG_CMP_MSC)
Dl_info dlinfo;
if (0 == dladdr(addr, &dlinfo))
return HGBASE_ERR_FAIL;
if (maxLen < strlen(dlinfo.dli_fname) + 1)
return HGBASE_ERR_FAIL;
strcpy(name, dlinfo.dli_fname);
if (NULL == addr)
{
char dir[PATH_MAX] = {0};
if (0 == readlink("/proc/self/exe", dir, PATH_MAX))
return HGBASE_ERR_FAIL;
if (maxLen < strlen(dir) + 1)
return HGBASE_ERR_FAIL;
strcpy(name, dir);
}
else
{
Dl_info dlinfo;
if (0 == dladdr(addr, &dlinfo))
return HGBASE_ERR_FAIL;
if (maxLen < strlen(dlinfo.dli_fname) + 1)
return HGBASE_ERR_FAIL;
strcpy(name, dlinfo.dli_fname);
}
#else
HMODULE hModule = NULL;
GetModuleHandleExA(GET_MODULE_HANDLE_EX_FLAG_FROM_ADDRESS
| GET_MODULE_HANDLE_EX_FLAG_UNCHANGED_REFCOUNT, (LPCSTR)addr, &hModule);
if (NULL == hModule)
return HGBASE_ERR_FAIL;
CHAR moduleName[MAX_PATH] = { 0 };
DWORD len = GetModuleFileNameA(hModule, moduleName, MAX_PATH);
@ -253,6 +264,32 @@ 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);
@ -291,6 +328,32 @@ HGResult HGAPI HGBase_GetLogFilePath(HGChar* logFilePath, 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(logFilePath, dataPath);
return HGBASE_ERR_OK;
}
#if defined(HG_CMP_MSC)
CHAR logPath[MAX_PATH] = { 0 };
BOOL ret = SHGetSpecialFolderPathA(NULL, logPath, CSIDL_APPDATA, FALSE);

View File

@ -108,4 +108,4 @@ int cgiMain()
//打印输出
fprintf(cgiOut, "<p> upload file success. </p>\n");
return cgiFormSuccess;
}
}