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

Loading…
Cancel
Save