Browse Source

fix binary files

pull/12/head
chertov 11 years ago
parent
commit
7d2281b477
  1. 6
      RouterContext.cpp
  2. 16
      RouterInfo.cpp
  3. 3
      TunnelConfig.h

6
RouterContext.cpp

@ -60,7 +60,7 @@ namespace i2p @@ -60,7 +60,7 @@ namespace i2p
bool RouterContext::Load ()
{
std::ifstream fk (ROUTER_KEYS);
std::ifstream fk (ROUTER_KEYS, std::ios::binary);
if (!fk.is_open ()) return false;
fk.read ((char *)&m_Keys, sizeof (m_Keys));
@ -74,10 +74,10 @@ namespace i2p @@ -74,10 +74,10 @@ namespace i2p
void RouterContext::Save ()
{
std::ofstream fk (ROUTER_KEYS);
std::ofstream fk (ROUTER_KEYS, std::ios::binary);
fk.write ((char *)&m_Keys, sizeof (m_Keys));
std::ofstream fi (ROUTER_INFO);
std::ofstream fi(ROUTER_INFO, std::ios::binary);
fi.write ((char *)m_RouterInfo.GetBuffer (), m_RouterInfo.GetBufferLen ());
}
}

16
RouterInfo.cpp

@ -41,7 +41,7 @@ namespace data @@ -41,7 +41,7 @@ namespace data
void RouterInfo::ReadFromFile (const char * filename)
{
std::ifstream s(filename);
std::ifstream s(filename, std::ios::binary);
if (s.is_open ())
{
s.seekg (0,std::ios::end);
@ -95,7 +95,7 @@ namespace data @@ -95,7 +95,7 @@ namespace data
size = be16toh (size);
while (r < size)
{
char key[50], value[50];
char key[500], value[500];
r += ReadString (key, s);
s.seekg (1, std::ios_base::cur); r++; // =
r += ReadString (value, s);
@ -117,7 +117,7 @@ namespace data @@ -117,7 +117,7 @@ namespace data
size = be16toh (size);
while (r < size)
{
char key[50], value[50];
char key[500], value[500];
r += ReadString (key, s);
s.seekg (1, std::ios_base::cur); r++; // =
r += ReadString (value, s);
@ -212,6 +212,16 @@ namespace data @@ -212,6 +212,16 @@ namespace data
{
uint8_t len;
s.read ((char *)&len, 1);
//static int count_l = 0;
//count_l++;
//std::cout << count_l << " " << (int)len << std::endl;
//if (len > 40)
//{
// std::cout << (int)len << std::endl;
//}
s.read (str, len);
str[len] = 0;
return len+1;

3
TunnelConfig.h

@ -115,8 +115,9 @@ namespace tunnel @@ -115,8 +115,9 @@ namespace tunnel
while (hop)
{
delete hop;
auto tmp = hop;
hop = hop->next;
delete tmp;
}
}

Loading…
Cancel
Save