Browse Source

* Family : use i2p::fs::ReadDir instead direct boost::filesystem call

pull/388/head
hagen 9 years ago
parent
commit
02310d4af6
  1. 28
      Family.cpp

28
Family.cpp

@ -1,7 +1,7 @@ @@ -1,7 +1,7 @@
#include <string.h>
#include "util.h"
#include <openssl/evp.h>
#include <openssl/ssl.h>
#include "FS.h"
#include "Log.h"
#include "Crypto.h"
#include "Family.h"
@ -84,20 +84,23 @@ namespace data @@ -84,20 +84,23 @@ namespace data
void Families::LoadCertificates ()
{
boost::filesystem::path familyDir = i2p::util::filesystem::GetCertificatesDir() / "family";
if (!boost::filesystem::exists (familyDir)) return;
std::string certDir = i2p::fs::DataDirPath("certificates", "family");
std::vector<std::string> files;
int numCertificates = 0;
boost::filesystem::directory_iterator end; // empty
for (boost::filesystem::directory_iterator it (familyDir); it != end; ++it)
{
if (boost::filesystem::is_regular_file (it->status()) && it->path ().extension () == ".crt")
{
LoadCertificate (it->path ().string ());
numCertificates++;
if (!i2p::fs::ReadDir(certDir, files)) {
LogPrint(eLogWarning, "Reseed: Can't load reseed certificates from ", certDir);
return;
}
for (const std::string & file : files) {
if (file.compare(file.size() - 4, 4, ".crt") != 0) {
LogPrint(eLogWarning, "Family: ignoring file ", file);
continue;
}
LoadCertificate (file);
numCertificates++;
}
if (numCertificates > 0)
LogPrint (eLogInfo, "Family: ", numCertificates, " certificates loaded");
}
@ -116,7 +119,6 @@ namespace data @@ -116,7 +119,6 @@ namespace data
// TODO: process key
return true;
}
}
}

Loading…
Cancel
Save