MCPcopy Create free account
hub / github.com/PurpleI2P/i2pd / LoadFile

Method LoadFile

libi2pd/RouterInfo.cpp:129–153  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

127 }
128
129 bool RouterInfo::LoadFile (const std::string& fullPath)
130 {
131 std::ifstream s(fullPath, std::ifstream::binary);
132 if (s.is_open ())
133 {
134 s.seekg (0,std::ios::end);
135 size_t bufferLen = s.tellg ();
136 if (bufferLen < 40 || bufferLen > MAX_RI_BUFFER_SIZE)
137 {
138 LogPrint(eLogError, "RouterInfo: File ", fullPath, " is malformed");
139 return false;
140 }
141 s.seekg(0, std::ios::beg);
142 if (!m_Buffer)
143 m_Buffer = NewBuffer ();
144 s.read((char *)m_Buffer->data (), bufferLen);
145 m_Buffer->SetBufferLen (bufferLen);
146 }
147 else
148 {
149 LogPrint (eLogError, "RouterInfo: Can't open file ", fullPath);
150 return false;
151 }
152 return true;
153 }
154
155 void RouterInfo::ReadFromFile (const std::string& fullPath)
156 {

Callers

nothing calls this directly

Calls 2

LogPrintFunction · 0.85
SetBufferLenMethod · 0.45

Tested by

no test coverage detected