|
@@ -10,8 +10,11 @@
|
|
|
#include <sys/types.h>
|
|
|
#include <sys/stat.h>
|
|
|
#include <unistd.h>
|
|
|
-#endif
|
|
|
+#endif
|
|
|
+#include <winpr/string.h>
|
|
|
+#include "SpUtility.h"
|
|
|
|
|
|
+//TODO: CrossPlaform 这个引入的库文件建议废除,用应用框架提供的替代 [Gifur@2025822]
|
|
|
|
|
|
int ReadInterger(LPCTSTR szSection, LPCTSTR szKey, LPCTSTR szFileName, int iDefaultValue)
|
|
|
{
|
|
@@ -57,44 +60,6 @@ string ReadString(LPCTSTR szSection, LPCTSTR szKey, LPCTSTR szFileName, LPCTSTR
|
|
|
return string(tempResult);
|
|
|
}
|
|
|
|
|
|
-void WriteBoolean(LPCTSTR szSection, LPCTSTR szKey, BOOL szBool, LPCTSTR szFileName)
|
|
|
-{
|
|
|
- TCHAR szDefault[MAX_PATH] = {0};
|
|
|
-#ifdef RVC_OS_WIN
|
|
|
- _stprintf_s(szDefault, _T("%d"), szBool);
|
|
|
- WritePrivateProfileString(szSection, szKey, szDefault, szFileName);
|
|
|
-#else
|
|
|
- snprintf(szDefault, MAX_PATH, "%d", szBool);
|
|
|
- inifile_write_str(szSection, szKey, szDefault, szFileName);
|
|
|
- //WritePrivateProfileStringEx(szSection, szKey, szDefault, szFileName);
|
|
|
-#endif
|
|
|
-}
|
|
|
-
|
|
|
-void WriteInt(LPCTSTR szSection, LPCTSTR szKey, int szInt, LPCTSTR szFileName)
|
|
|
-{
|
|
|
- TCHAR szDefault[MAX_PATH] = { 0 };
|
|
|
- //TODO: CrossPlaform [Gifur@2025730]
|
|
|
-#ifdef RVC_OS_WIN
|
|
|
- _stprintf_s(szDefault, _T("%d"), szInt);
|
|
|
- WritePrivateProfileString(szSection, szKey, szDefault, szFileName);
|
|
|
-#else
|
|
|
- //snprintf(szDefault, MAX_PATH, "%d", szInt);
|
|
|
- inifile_write_int(szFileName,szSection, szKey, szInt);
|
|
|
- //WritePrivateProfileStringEx(szSection, szKey, szDefault, szFileName);
|
|
|
-#endif
|
|
|
-}
|
|
|
-
|
|
|
-void WriteString(LPCTSTR szSection, LPCTSTR szKey, LPCTSTR szString, LPCTSTR szFileName)
|
|
|
-{
|
|
|
- //TODO: CrossPlaform [Gifur@2025730]
|
|
|
-#ifdef RVC_OS_WIN
|
|
|
- WritePrivateProfileString(szSection, szKey, szString, szFileName);
|
|
|
-#else
|
|
|
- inifile_write_str(szSection, szKey, szString, szFileName);
|
|
|
- //WritePrivateProfileStringEx(szSection, szKey, szString, szFileName);
|
|
|
-#endif
|
|
|
-}
|
|
|
-
|
|
|
bool checkInPlayTime(string playTime, bool checkCurTime)
|
|
|
{
|
|
|
//get localTime
|
|
@@ -113,13 +78,7 @@ bool checkInPlayTime(string playTime, bool checkCurTime)
|
|
|
t_beginHour = t_beginMin = t_endHour = t_endMin = 0;
|
|
|
try
|
|
|
{
|
|
|
- //TODO: CrossPlaform [Gifur@2025730]
|
|
|
-#ifdef RVC_OS_WIN
|
|
|
sscanf_s(playTime.c_str(), "%d:%d-%d:%d", &t_beginHour, &t_beginMin, &t_endHour, &t_endMin);
|
|
|
-#else
|
|
|
- sscanf(playTime.c_str(), "%d:%d-%d:%d", &t_beginHour, &t_beginMin, &t_endHour, &t_endMin);
|
|
|
-#endif // RVC_OS_WIN
|
|
|
-
|
|
|
long curTime = local.tm_hour * 3600 + local.tm_min * 60 + local.tm_sec;
|
|
|
long beginTime = t_beginHour * 3600 + t_beginMin * 60;
|
|
|
long endTime = t_endHour * 3600 + t_endMin * 60 + 60;
|
|
@@ -154,37 +113,22 @@ bool checkInVaildTime(string vaildTime, bool checkCurData)
|
|
|
#endif // RVC_OS_WIN
|
|
|
|
|
|
vector<string> dateList;
|
|
|
- split(vaildTime, ",", dateList);
|
|
|
+ SP::Utility::split2(vaildTime, ",", dateList);
|
|
|
try {
|
|
|
for (vector<string>::iterator i = dateList.begin(); i != dateList.end(); i++)
|
|
|
{
|
|
|
tm beginData = { 0 }, endData = {0};
|
|
|
int tempYear, tempMon, tempDay, tempYear2, tempMon2, tempDay2;
|
|
|
tempYear = tempMon = tempDay = tempYear2 = tempMon2 = tempDay2 = 0;
|
|
|
- //ZeroMemory(&beginData, sizeof(tm));
|
|
|
- //ZeroMemory(&endData, sizeof(tm));
|
|
|
if (-1 == i->find('-')) //单日期
|
|
|
{
|
|
|
- //TODO: CrossPlaform [Gifur@2025730]
|
|
|
-#ifdef RVC_OS_WIN
|
|
|
sscanf_s(i->c_str(), "%d/%d/%d", &tempYear, &tempMon, &tempDay);
|
|
|
-#else
|
|
|
- sscanf(i->c_str(), "%d/%d/%d", &tempYear, &tempMon, &tempDay);
|
|
|
-#endif // RVC_OS_WIN
|
|
|
-
|
|
|
-
|
|
|
if (checkCurData && (local.tm_year + 1900 == tempYear) && (local.tm_mon + 1 == tempMon) && (local.tm_mday == tempDay))
|
|
|
return true;//find the data
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
- //TODO: CrossPlaform [Gifur@2025730]
|
|
|
-#ifdef RVC_OS_WIN
|
|
|
sscanf_s(i->c_str(), "%d/%d/%d-%d/%d/%d", &tempYear, &tempMon, &tempDay, &tempYear2, &tempMon2, &tempDay2);
|
|
|
-#else
|
|
|
- sscanf(i->c_str(), "%d/%d/%d-%d/%d/%d", &tempYear, &tempMon, &tempDay, &tempYear2, &tempMon2, &tempDay2);
|
|
|
-#endif // RVC_OS_WIN
|
|
|
-
|
|
|
beginData.tm_year = tempYear - 1900;
|
|
|
beginData.tm_mon = tempMon - 1;
|
|
|
beginData.tm_mday = tempDay;
|
|
@@ -213,6 +157,7 @@ bool checkInVaildTime(string vaildTime, bool checkCurData)
|
|
|
|
|
|
bool parseResourceIni(const char* filePath, vector<ResourceParse> &ret)
|
|
|
{
|
|
|
+ /** 这段代码的意义在哪?如果只是判断文件在不在,直接用ExistFileA的跨平台函数即可 [Gifur@2025822]*/
|
|
|
#ifdef RVC_OS_WIN
|
|
|
if (INVALID_FILE_ATTRIBUTES == GetFileAttributes(filePath))
|
|
|
{
|
|
@@ -237,14 +182,7 @@ bool parseResourceIni(const char* filePath, vector<ResourceParse> &ret)
|
|
|
{
|
|
|
//get section name
|
|
|
TCHAR sectionMedia[30] = STR_NULL;
|
|
|
- //TODO: CrossPlaform [Gifur@2025730]
|
|
|
-#ifdef RVC_OS_WIN
|
|
|
- _stprintf_s(sectionMedia, _T("%s%d"), SECTION_MEDIA, i);
|
|
|
-#else
|
|
|
- snprintf(sectionMedia, 30, "%s%d", SECTION_MEDIA, i);
|
|
|
-#endif // RVC_OS_WIN
|
|
|
-
|
|
|
- //ResourceParse curResource;
|
|
|
+ sprintf_s(sectionMedia, 30, "%s%d", SECTION_MEDIA, i);
|
|
|
ResourceParse* item = new ResourceParse();
|
|
|
//获取type属性及校验
|
|
|
string type = ReadString(sectionMedia, MEDIA_TYPE, filePath, STR_NULL);
|
|
@@ -271,18 +209,3 @@ bool parseResourceIni(const char* filePath, vector<ResourceParse> &ret)
|
|
|
return false;
|
|
|
return true;
|
|
|
}
|
|
|
-
|
|
|
-
|
|
|
-int ReleaseCResourceArrs(CResourceParse** resourceArr, uint32_t uSize)
|
|
|
-{
|
|
|
- int iRet = 0;
|
|
|
- for (int i = 0; i < uSize; i++) {
|
|
|
- if (resourceArr && resourceArr[i]){
|
|
|
- CResourceParse* pData = resourceArr[i];
|
|
|
- delete pData;
|
|
|
- resourceArr[i] = NULL;
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
- return iRet;
|
|
|
-}
|