linux上实现从配置文件中获取cfg和log目录
This commit is contained in:
parent
5b17ef350d
commit
d4408d530f
|
@ -168,7 +168,7 @@ SOURCES += \
|
||||||
../../../modules/base/HGMd5.cpp \
|
../../../modules/base/HGMd5.cpp \
|
||||||
../../../modules/base/HGUtility.cpp \
|
../../../modules/base/HGUtility.cpp \
|
||||||
../../../modules/base/HGThread.cpp \
|
../../../modules/base/HGThread.cpp \
|
||||||
../../../utility/HGString.cpp
|
../../../utility/HGString.cpp \
|
||||||
|
|
||||||
HEADERS += \
|
HEADERS += \
|
||||||
../../../app/upgrade/HGUpgrade.h \
|
../../../app/upgrade/HGUpgrade.h \
|
||||||
|
@ -177,7 +177,7 @@ HEADERS += \
|
||||||
../../../modules/base/HGMd5.h \
|
../../../modules/base/HGMd5.h \
|
||||||
../../../modules/base/HGUtility.h \
|
../../../modules/base/HGUtility.h \
|
||||||
../../../modules/base/HGThread.h \
|
../../../modules/base/HGThread.h \
|
||||||
../../../utility/HGString.h
|
../../../utility/HGString.h \
|
||||||
|
|
||||||
FORMS += \
|
FORMS += \
|
||||||
../../../app/upgrade/mainwindow.ui
|
../../../app/upgrade/mainwindow.ui
|
||||||
|
|
|
@ -168,6 +168,8 @@
|
||||||
<Add option="-z defs" />
|
<Add option="-z defs" />
|
||||||
<Add option="-B direct" />
|
<Add option="-B direct" />
|
||||||
</Linker>
|
</Linker>
|
||||||
|
<Unit filename="../../../modules/base/HGIni.cpp" />
|
||||||
|
<Unit filename="../../../modules/base/HGIni.h" />
|
||||||
<Unit filename="../../../modules/base/HGUtility.cpp" />
|
<Unit filename="../../../modules/base/HGUtility.cpp" />
|
||||||
<Unit filename="../../../modules/base/HGUtility.h" />
|
<Unit filename="../../../modules/base/HGUtility.h" />
|
||||||
<Unit filename="../../../sdk/upload/main.cpp" />
|
<Unit filename="../../../sdk/upload/main.cpp" />
|
||||||
|
|
|
@ -171,12 +171,24 @@ HGResult HGAPI HGBase_GetModuleName(HGPointer addr, HGChar* name, HGUInt maxLen)
|
||||||
}
|
}
|
||||||
|
|
||||||
#if !defined(HG_CMP_MSC)
|
#if !defined(HG_CMP_MSC)
|
||||||
Dl_info dlinfo;
|
if (NULL == addr)
|
||||||
if (0 == dladdr(addr, &dlinfo))
|
{
|
||||||
return HGBASE_ERR_FAIL;
|
char dir[PATH_MAX] = {0};
|
||||||
if (maxLen < strlen(dlinfo.dli_fname) + 1)
|
if (0 == readlink("/proc/self/exe", dir, PATH_MAX))
|
||||||
return HGBASE_ERR_FAIL;
|
return HGBASE_ERR_FAIL;
|
||||||
strcpy(name, dlinfo.dli_fname);
|
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
|
#else
|
||||||
HMODULE hModule = NULL;
|
HMODULE hModule = NULL;
|
||||||
GetModuleHandleExA(GET_MODULE_HANDLE_EX_FLAG_FROM_ADDRESS
|
GetModuleHandleExA(GET_MODULE_HANDLE_EX_FLAG_FROM_ADDRESS
|
||||||
|
@ -252,7 +264,7 @@ HGResult HGAPI HGBase_GetConfigPath(HGChar* configPath, HGUInt maxLen)
|
||||||
return HGBASE_ERR_INVALIDARG;
|
return HGBASE_ERR_INVALIDARG;
|
||||||
}
|
}
|
||||||
|
|
||||||
HGChar moduleName[56];
|
HGChar moduleName[256];
|
||||||
HGBase_GetModuleName(NULL, moduleName, 256);
|
HGBase_GetModuleName(NULL, moduleName, 256);
|
||||||
HGChar modulePath[256];
|
HGChar modulePath[256];
|
||||||
HGBase_GetFilePath(moduleName, modulePath, 256);
|
HGBase_GetFilePath(moduleName, modulePath, 256);
|
||||||
|
@ -269,7 +281,7 @@ HGResult HGAPI HGBase_GetConfigPath(HGChar* configPath, HGUInt maxLen)
|
||||||
#else
|
#else
|
||||||
if (dataPath[strlen(dataPath) - 1] != '/')
|
if (dataPath[strlen(dataPath) - 1] != '/')
|
||||||
strcat(dataPath, "/");
|
strcat(dataPath, "/");
|
||||||
strcat(cfgPath, "Cfg/");
|
strcat(dataPath, "Cfg/");
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
if (maxLen < strlen(dataPath) + 1)
|
if (maxLen < strlen(dataPath) + 1)
|
||||||
|
@ -316,7 +328,7 @@ HGResult HGAPI HGBase_GetLogFilePath(HGChar* logFilePath, HGUInt maxLen)
|
||||||
return HGBASE_ERR_INVALIDARG;
|
return HGBASE_ERR_INVALIDARG;
|
||||||
}
|
}
|
||||||
|
|
||||||
HGChar moduleName[56];
|
HGChar moduleName[256];
|
||||||
HGBase_GetModuleName(NULL, moduleName, 256);
|
HGBase_GetModuleName(NULL, moduleName, 256);
|
||||||
HGChar modulePath[256];
|
HGChar modulePath[256];
|
||||||
HGBase_GetFilePath(moduleName, modulePath, 256);
|
HGBase_GetFilePath(moduleName, modulePath, 256);
|
||||||
|
@ -333,7 +345,7 @@ HGResult HGAPI HGBase_GetLogFilePath(HGChar* logFilePath, HGUInt maxLen)
|
||||||
#else
|
#else
|
||||||
if (dataPath[strlen(dataPath) - 1] != '/')
|
if (dataPath[strlen(dataPath) - 1] != '/')
|
||||||
strcat(dataPath, "/");
|
strcat(dataPath, "/");
|
||||||
strcat(cfgPath, "Cfg/");
|
strcat(dataPath, "Cfg/");
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
if (maxLen < strlen(dataPath) + 1)
|
if (maxLen < strlen(dataPath) + 1)
|
||||||
|
|
|
@ -108,4 +108,4 @@ int cgiMain()
|
||||||
//打印输出
|
//打印输出
|
||||||
fprintf(cgiOut, "<p> upload file success. </p>\n");
|
fprintf(cgiOut, "<p> upload file success. </p>\n");
|
||||||
return cgiFormSuccess;
|
return cgiFormSuccess;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue