本文整理汇总了C++中CFile::ReadUInt8方法的典型用法代码示例。如果您正苦于以下问题:C++ CFile::ReadUInt8方法的具体用法?C++ CFile::ReadUInt8怎么用?C++ CFile::ReadUInt8使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CFile
的用法示例。
在下文中一共展示了CFile::ReadUInt8方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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;
}