本文整理汇总了C++中CFile::ReadUInt32方法的典型用法代码示例。如果您正苦于以下问题:C++ CFile::ReadUInt32方法的具体用法?C++ CFile::ReadUInt32怎么用?C++ CFile::ReadUInt32使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CFile
的用法示例。
在下文中一共展示了CFile::ReadUInt32方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: LoadList
void CFriendList::LoadList()
{
CPath metfile = CPath(theApp->ConfigDir + wxT("emfriends.met"));
if (!metfile.FileExists()) {
return;
}
CFile file;
try {
if ( file.Open(metfile) ) {
if ( file.ReadUInt8() /*header*/ == MET_HEADER ) {
uint32 nRecordsNumber = file.ReadUInt32();
for (uint32 i = 0; i < nRecordsNumber; i++) {
CFriend* Record = new CFriend();
Record->LoadFromFile(&file);
m_FriendList.push_back(Record);
Notify_ChatUpdateFriend(Record);
}
}
} else {
AddLogLineN(_("Failed to open friend list file 'emfriends.met' for reading!"));
}
} catch (const CInvalidPacket& e) {
AddDebugLogLineC(logGeneral, wxT("Invalid entry in friend list, file may be corrupt: ") + e.what());
} catch (const CSafeIOException& e) {
AddDebugLogLineC(logGeneral, wxT("IO error while reading 'emfriends.met': ") + e.what());
}
}
示例2: Init
bool CKnownFileList::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)) {
AddLogLineC(CFormat(_("WARNING: %s cannot be opened.")) % m_filename);
return false;
}
try {
uint8 version = file.ReadUInt8();
if ((version != MET_HEADER) && (version != MET_HEADER_WITH_LARGEFILES)) {
AddLogLineC(_("WARNING: Known file list corrupted, contains invalid header."));
return false;
}
wxMutexLocker sLock(list_mut);
uint32 RecordsNumber = file.ReadUInt32();
AddDebugLogLineN(logKnownFiles, CFormat(wxT("Reading %i known files from file format 0x%2.2x."))
% RecordsNumber % version);
for (uint32 i = 0; i < RecordsNumber; i++) {
CScopedPtr<CKnownFile> record;
if (record->LoadFromFile(&file)) {
AddDebugLogLineN(logKnownFiles,
CFormat(wxT("Known file read: %s")) % record->GetFileName());
Append(record.release());
} else {
AddLogLineC(_("Failed to load entry in known file list, file may be corrupt"));
}
}
AddDebugLogLineN(logKnownFiles, wxT("Finished reading known files"));
return true;
} catch (const CInvalidPacket& e) {
AddLogLineC(_("Invalid entry in known file list, file may be corrupt: ") + e.what());
} catch (const CSafeIOException& e) {
AddLogLineC(CFormat(_("IO error while reading %s file: %s")) % m_filename % e.what());
}
return false;
}
示例3: Init
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: ReadFile
void CPrefs::ReadFile()
{
const CPath path = CPath(m_filename);
try {
CFile file;
if (path.FileExists() && file.Open(path, CFile::read)) {
m_ip = file.ReadUInt32();
file.ReadUInt16();
m_clientID = file.ReadUInt128();
// get rid of invalid kad IDs which may have been stored by older versions
if (m_clientID == 0)
m_clientID = GetRandomUint128();
file.Close();
}
} catch (const CSafeIOException& e) {
AddDebugLogLineC(logKadPrefs, wxT("IO error while reading prefs: ") + e.what());
}
}
示例5: OpenCollectionInBinaryFormat
bool collection::OpenCollectionInBinaryFormat(wxString file)
{
CFile File;
if(File.Open(file, CFile::read, 0))
{
try
{
uint32 nVersion = File.ReadUInt32();
if(nVersion == 0x01 || nVersion == 0x02)
{
uint32 headerTagCount = File.ReadUInt32();
while(headerTagCount)
{
CTag tag(File, true);
switch(tag.GetNameID())
{
case 0x01:
{
if(tag.IsStr())
CollectionName = tag.GetStr();
break;
}
case 0x31:
{
if(tag.IsStr())
CollectionAuthorName = tag.GetStr();
break;
}
case 0x32:
{
if(tag.IsBlob())
{
const byte* abyCollectionAuthorKey = tag.GetBlob();
uint32 nSize = tag.GetBlobSize();
byte* m_pabyCollectionAuthorKey;
uint32 m_nKeySize;
delete[] m_pabyCollectionAuthorKey;
m_pabyCollectionAuthorKey = NULL;
m_nKeySize = 0;
if (abyCollectionAuthorKey != NULL){
m_pabyCollectionAuthorKey = new byte[nSize];
memcpy(m_pabyCollectionAuthorKey, abyCollectionAuthorKey, nSize);
m_nKeySize = nSize;
}
}
break;
}
}
headerTagCount--;
}
if (CollectionName==wxT("")) {
return false;
}
uint32 fileCount = File.ReadUInt32();
while(fileCount)
{
//#################################################
wxString fname, fhash, ftype;
CMD4Hash md4hash;
int fsize;
uint tagcount = File.ReadUInt32();
CTag* taglist[tagcount];
for (uint i = 0; i < tagcount; i++)
{
CTag* toadd = new CTag(File, true);
if (toadd)
taglist[i] = toadd;
}
int i = 0;
do
{
if (taglist[i]->GetNameID()==0x28) {
md4hash = taglist[i]->GetHash();
fhash = md4hash.Encode();
}
i++;
}
while (i < tagcount);
i = 0;
do
{
if (taglist[i]->GetNameID()==0x03 && taglist[i]->IsStr()) {
ftype = taglist[i]->GetStr();
}
i++;
}
while (i < tagcount);
i = 0;
do
{
if (taglist[i]->GetNameID()==0x01 && taglist[i]->IsStr()) {
//.........这里部分代码省略.........
示例6: ReadFile
void CRoutingZone::ReadFile(const wxString& specialNodesdat)
{
if (m_superZone != NULL || (m_filename.IsEmpty() && specialNodesdat.IsEmpty())) {
wxFAIL;
return;
}
bool doHaveVerifiedContacts = false;
// Read in the saved contact list
try {
uint32_t numContacts = 0;
uint32_t validContacts = 0;
CFile file;
if (CPath::FileExists(specialNodesdat.IsEmpty() ? m_filename : specialNodesdat) && file.Open(m_filename, CFile::read)) {
// Get how many contacts in the saved list.
// NOTE: Older clients put the number of contacts here...
// Newer clients always have 0 here to prevent older clients from reading it.
numContacts = file.ReadUInt32();
uint32_t fileVersion = 0;
if (numContacts == 0) {
if (file.GetLength() >= 8) {
fileVersion = file.ReadUInt32();
if (fileVersion == 3) {
uint32_t bootstrapEdition = file.ReadUInt32();
if (bootstrapEdition == 1) {
// this is a special bootstrap-only nodes.dat, handle it in a separate reading function
ReadBootstrapNodesDat(file);
file.Close();
return;
}
}
if (fileVersion >= 1 && fileVersion <= 3) {
numContacts = file.ReadUInt32();
}
}
} else {
// Don't read version 0 nodes.dat files, because they can't tell the kad version of the contacts stored.
AddLogLineC(_("Failed to read nodes.dat file - too old. This version (0) is not supported anymore."));
numContacts = 0;
}
DEBUG_ONLY( unsigned kad1Count = 0; )
if (numContacts != 0 && numContacts * 25 <= (file.GetLength() - file.GetPosition())) {
for (uint32_t i = 0; i < numContacts; i++) {
CUInt128 id = file.ReadUInt128();
uint32_t ip = file.ReadUInt32();
uint16_t udpPort = file.ReadUInt16();
uint16_t tcpPort = file.ReadUInt16();
uint8_t contactVersion = 0;
contactVersion = file.ReadUInt8();
CKadUDPKey kadUDPKey;
bool verified = false;
if (fileVersion >= 2) {
kadUDPKey.ReadFromFile(file);
verified = file.ReadUInt8() != 0;
if (verified) {
doHaveVerifiedContacts = true;
}
}
// IP appears valid
if (contactVersion > 1) {
if(IsGoodIPPort(wxUINT32_SWAP_ALWAYS(ip),udpPort)) {
if (!theApp->ipfilter->IsFiltered(wxUINT32_SWAP_ALWAYS(ip)) &&
!(udpPort == 53 && contactVersion <= 5 /*No DNS Port without encryption*/)) {
// This was not a dead contact, inc counter if add was successful
if (AddUnfiltered(id, ip, udpPort, tcpPort, contactVersion, kadUDPKey, verified, false, false)) {
validContacts++;
}
}
}
} else {
DEBUG_ONLY( kad1Count++; )
}
}
}
file.Close();
AddLogLineN(CFormat(wxPLURAL("Read %u Kad contact", "Read %u Kad contacts", validContacts)) % validContacts);
#ifdef __DEBUG__
if (kad1Count > 0) {
AddDebugLogLineN(logKadRouting, CFormat(wxT("Ignored %u kad1 %s in nodes.dat file.")) % kad1Count % (kad1Count > 1 ? wxT("contacts"): wxT("contact")));
}
#endif
if (!doHaveVerifiedContacts) {
AddDebugLogLineN(logKadRouting, wxT("No verified contacts found in nodes.dat - might be an old file version. Setting all contacts verified for this time to speed up Kad bootstrapping."));
SetAllContactsVerified();
}
}