示例#1
0
/**
 * Creates a new CECTag instance, which contains a MD4 hash.
 *
 * This function takes care to store hash in network byte order.
 *
 * @param name TAG name
 * @param data The CMD4Hash class containing the MD4 hash.
 *
 * @see GetMD4Data()
 */
CECTag::CECTag(ec_tagname_t name, const CMD4Hash& data) : m_tagName(name)
{
	m_dataLen = 16;
	NewData();
	RawPokeUInt64( m_tagData,		RawPeekUInt64( data.GetHash() ) );
	RawPokeUInt64( m_tagData + 8,	RawPeekUInt64( data.GetHash() + 8 ) );
	m_dataType = EC_TAGTYPE_HASH16;
}
示例#2
0
CMD4Hash CFileDataIO::ReadHash() const
{
	CMD4Hash value;
	Read(value.GetHash(), MD4HASH_LENGTH);

	return value;
}
示例#3
0
bool CCanceledFileList::Init()
{
	CFile file;
	
	CPath fullpath = CPath(theApp->ConfigDir + m_filename);
	if (!fullpath.FileExists()) {
		// This is perfectly normal. The file was probably either
		// deleted, or this is the first time running aMule.
		return false;
	}

	if (!file.Open(fullpath)) {
		AddLogLineM(true, CFormat(_("WARNING: %s cannot be opened.")) % m_filename);
		return false;
	}
	
	try {
		uint8 version = file.ReadUInt8();
		if (version != CANCELEDFILE_VERSION) {
			AddLogLineM(true, _("WARNING: Canceled file list corrupted, contains invalid header."));
			return false;
		}
		
		uint32 RecordsNumber = file.ReadUInt32();
		AddDebugLogLineM(false, logKnownFiles,
			CFormat(wxT("Reading %i canceled files from file format 0x%02x."))
			% RecordsNumber % version);
		for (uint32 i = 0; i < RecordsNumber; i++) {
			CMD4Hash hash;
			file.Read(hash.GetHash(), 16);
			AddDebugLogLineM(false, logKnownFiles, CFormat(wxT("Canceled file read: %s")) % hash.Encode());
			if (!hash.IsEmpty()) {
				m_canceledFileList.insert(hash);
			}
		}
		AddDebugLogLineM(false, logKnownFiles, wxT("Finished reading canceled files"));
	
		return true;
	} catch (const CSafeIOException& e) {
		AddLogLineM(true, CFormat(_("IO error while reading %s file: %s")) % m_filename % e.what());
	}	
	
	return false;
}
示例#4
0
void CFileDataIO::WriteHash(const CMD4Hash& value)
{
	Write(value.GetHash(), MD4HASH_LENGTH);
}