有A.txt 文件保存ini的键,从B.ini提取具有相同值的键。
函数思想:1.需要按行提取A.txt文件里的字符串作键去读取B.ini里的信息
2.读取到值(设为V),后需要读取其他键下相对应的值。那么就需要循环做步骤1.同时需要将当前的键排除,直到A.txt的文件结尾
函数实现:
void CheckTheSame(std::string filePath = "", std::wstring gtURL = L"", std::wstring gtwin7Url = L"")
{
FILE *fRead;
fRead = fopen(filePath.c_str(), "r");
if (fRead)
{
int buffLen = 4096;
char line[4096 + 1];
char *pLine = line;
std::wstring SameURl = gtURL;
while (!feof(fRead))
{
int i = 0;
while (!feof(fRead) && i < buffLen) //getline
{
char temp = fgetc(fRead);
if (temp)
{
*(pLine + i) = temp;
i++;
if (temp == 10) //\n 换行标识符号
break;
}
}
*(pLine + i) = 0;
wchar_t *wURL = StringAct::c2w(pLine);
wchar_t *wtemp = wcschr(wURL, ' ');
if (wtemp)
*wtemp = 0;
else
{
wtemp = wcschr(wURL, '\n');
if (wtemp)
*wtemp = 0;
}
wprintf(L"Down--%s\n", wURL);
std::wstring URL = L"http://";
URL += wURL;
URL += L"/";
StringAct::freeWChar(wURL);
//校验
wchar_t * url = L"SameSection";
std::wstring downsInfo = FLYLIB::AppInfo::GetCurrentThisPath();
downsInfo += L"downInfo.ini";
wchar_t downUrl[1024];
if (GetPrivateProfileString(URL.c_str(), url, L"", downUrl, 512, downsInfo.c_str()))
{
if (!gtURL.empty())
{
if ((URL != gtURL) && (gtwin7Url == downUrl))
{
SameURl += L"|";
SameURl += URL;
}
}
else
{
CheckDown(filePath, URL, downUrl);
}
}
}
fclose(fRead);
if (!SameURl.empty())
{
wprintf("%s", SameURl.c_str())
FILE *fWrite;
std::string urlPath = FLYLIB::AppInfo::GetCurrentThisPathA();
urlPath += "downUrlCheck.txt";
fWrite = fopen(urlPath.c_str(), "a");
if (fWrite)
{
SameURl += L"\n";
char* temp = StringAct::w2c(SameURl.c_str());
fwrite(temp, 1, strlen(temp), fWrite);
StringAct::freeChar(temp);
fclose(fWrite);
}
}
}
}