Пример #1
0
BOOL CWizKMDatabaseServer::data_upload(const QString& strObjectGUID, const QString& strObjectType, const QByteArray& stream, const QString& strObjMD5, const QString& strDisplayName)
{
    __int64 nStreamSize = stream.size();
    if (0 == nStreamSize)
    {
        TOLOG(_T("fault error: stream is zero"));
        return FALSE;
    }
    //
    QString strMD5(strObjMD5);
    //
    QByteArray spPartStream;
    //
    int partSize = 500 * 1000;
    int partCount = int(nStreamSize / partSize);
    if (nStreamSize % partSize != 0)
    {
        partCount++;
    }
    //
    for (int i = 0; i < partCount; i++)
    {
        spPartStream.clear();

        int start = i * partSize;
        int end = std::min<int>(start + partSize, int(nStreamSize));
        ATLASSERT(end > start);
        //
        int curPartSize = end - start;
        ATLASSERT(curPartSize <= partSize);
        //
        const char* begin = stream.data() + start;
        spPartStream = spPartStream.fromRawData(begin, curPartSize);
        //
        int curPartStreamSize = (int)spPartStream.size();
        ATLASSERT(curPartStreamSize == curPartSize);
        //
        if (!data_upload(strObjectGUID, strObjectType, strMD5, (int)nStreamSize, partCount, i, curPartSize, spPartStream))
        {
            TOLOG1(_T("Failed to upload part data: %1"), strDisplayName);
            return FALSE;
        }
    }
    //
    //
    return TRUE;
}
Пример #2
-1
void CFilesHashDlg::AppendResult(const ResultData& result, CString& strToAppend)
{
	strToAppend.Append(FILENAME_STRING);
	strToAppend.Append(_T(" "));
	strToAppend.Append(result.strPath);
	strToAppend.Append(_T("\r\n"));
	if(result.bDone)
	{
		// A succeed result
		strToAppend.Append(FILESIZE_STRING);
		strToAppend.Append(_T(" "));
		strToAppend.AppendFormat(_T("%I64u "), result.ulSize);
		strToAppend.Append(BYTE_STRING);
		strToAppend.Append(ConvertSizeToCStr(result.ulSize));
		strToAppend.Append(_T("\r\n"));
		strToAppend.Append(MODIFYTIME_STRING);
		strToAppend.Append(_T(" "));
		strToAppend.Append(result.strMDate);
		if(result.strVersion.Compare(_T("")) != 0)
		{
			strToAppend.Append(_T("\r\n"));
			strToAppend.Append(VERSION_STRING);
			strToAppend.Append(_T(" "));
			strToAppend.Append(result.strVersion);
		}
		strToAppend.Append(_T("\r\n"));

		CString strMD5(result.strMD5);
		CString strSHA1(result.strSHA1);
		CString strSHA256(result.strSHA256);
		CString strCRC32(result.strCRC32);

		if(m_thrdData.uppercase = m_chkUppercase.GetCheck())
		{
			strToAppend.Append(_T("MD5: "));
			strToAppend.Append(strMD5.MakeUpper());
			strToAppend.Append(_T("\r\nSHA1: "));
			strToAppend.Append(strSHA1.MakeUpper());
			strToAppend.Append(_T("\r\nSHA256: "));
			strToAppend.Append(strSHA256.MakeUpper());
			strToAppend.Append(_T("\r\nCRC32: "));
			strToAppend.Append(strCRC32.MakeUpper());
		}
		else
		{
			strToAppend.Append(_T("MD5: "));
			strToAppend.Append(strMD5.MakeLower());
			strToAppend.Append(_T("\r\nSHA1: "));
			strToAppend.Append(strSHA1.MakeLower());
			strToAppend.Append(_T("\r\nSHA256: "));
			strToAppend.Append(strSHA256.MakeLower());
			strToAppend.Append(_T("\r\nCRC32: "));
			strToAppend.Append(strCRC32.MakeLower());
		}
	}
	else
	{
		// An error result
		strToAppend.Append(result.strError);
	}

	strToAppend.Append(_T("\r\n\r\n"));
}