MCPcopy Create free account
hub / github.com/amule-project/amule / Init

Method Init

src/CanceledFileList.cpp:42–85  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

40
41
42bool CCanceledFileList::Init()
43{
44 CFile file;
45
46 CPath fullpath = CPath(thePrefs::GetConfigDir() + m_filename);
47 if (!fullpath.FileExists()) {
48 // This is perfectly normal. The file was probably either
49 // deleted, or this is the first time running aMule.
50 return false;
51 }
52
53 if (!file.Open(fullpath)) {
54 AddLogLineC(CFormat(_("WARNING: %s cannot be opened.")) % m_filename);
55 return false;
56 }
57
58 try {
59 uint8 version = file.ReadUInt8();
60 if (version != CANCELEDFILE_VERSION) {
61 AddLogLineC(_("WARNING: Canceled file list corrupted, contains invalid header."));
62 return false;
63 }
64
65 uint32 RecordsNumber = file.ReadUInt32();
66 AddDebugLogLineN(logKnownFiles,
67 CFormat("Reading %i canceled files from file format 0x%02x.")
68 % RecordsNumber % version);
69 for (uint32 i = 0; i < RecordsNumber; i++) {
70 CMD4Hash hash;
71 file.Read(hash.GetHash(), 16);
72 AddDebugLogLineN(logKnownFiles, CFormat("Canceled file read: %s") % hash.Encode());
73 if (!hash.IsEmpty()) {
74 m_canceledFileList.insert(hash);
75 }
76 }
77 AddDebugLogLineN(logKnownFiles, "Finished reading canceled files");
78
79 return true;
80 } catch (const CSafeIOException& e) {
81 AddLogLineC(CFormat(_("IO error while reading %s file: %s")) % m_filename % e.what());
82 }
83
84 return false;
85}
86
87
88void CCanceledFileList::Save()

Callers

nothing calls this directly

Calls 13

GetConfigDirFunction · 0.85
CFormatClass · 0.85
FileExistsMethod · 0.80
ReadUInt8Method · 0.80
ReadUInt32Method · 0.80
insertMethod · 0.80
whatMethod · 0.80
CPathClass · 0.70
OpenMethod · 0.45
ReadMethod · 0.45
GetHashMethod · 0.45
EncodeMethod · 0.45

Tested by

no test coverage detected