summaryrefslogtreecommitdiff
path: root/nss-tool/db
diff options
context:
space:
mode:
authorTim Taubert <ttaubert@mozilla.com>2017-05-23 16:21:47 +0200
committerTim Taubert <ttaubert@mozilla.com>2017-05-23 16:21:47 +0200
commit0e2c3a95816319d108edfd85bd467942b95232cc (patch)
tree4801c7518fc4aa1f81dea784841dc91cc68526bf /nss-tool/db
parent5eccc68a88e91b28316b440f3c6d4309a6c6efd2 (diff)
downloadnss-hg-0e2c3a95816319d108edfd85bd467942b95232cc.tar.gz
Bug 1358134 - Don't use dirent.h in DBTool to check whether a DB exists r=franziskus
Differential Revision: https://nss-review.dev.mozaws.net/D326
Diffstat (limited to 'nss-tool/db')
-rw-r--r--nss-tool/db/dbtool.cc17
1 files changed, 8 insertions, 9 deletions
diff --git a/nss-tool/db/dbtool.cc b/nss-tool/db/dbtool.cc
index 5bdeec56e..8c369cf05 100644
--- a/nss-tool/db/dbtool.cc
+++ b/nss-tool/db/dbtool.cc
@@ -7,7 +7,6 @@
#include "scoped_ptrs.h"
#include "util.h"
-#include <dirent.h>
#include <iomanip>
#include <iostream>
#include <regex>
@@ -171,24 +170,24 @@ bool DBTool::PathHasDBFiles(std::string path) {
std::regex certDBPattern("cert.*\\.db");
std::regex keyDBPattern("key.*\\.db");
- DIR *dir;
- if (!(dir = opendir(path.c_str()))) {
+ PRDir *dir = PR_OpenDir(path.c_str());
+ if (!dir) {
std::cerr << "Directory " << path << " could not be accessed!" << std::endl;
return false;
}
- struct dirent *ent;
+ PRDirEntry *ent;
bool dbFileExists = false;
- while ((ent = readdir(dir))) {
- if (std::regex_match(ent->d_name, certDBPattern) ||
- std::regex_match(ent->d_name, keyDBPattern) ||
- "secmod.db" == std::string(ent->d_name)) {
+ while ((ent = PR_ReadDir(dir, PR_SKIP_BOTH))) {
+ if (std::regex_match(ent->name, certDBPattern) ||
+ std::regex_match(ent->name, keyDBPattern) ||
+ "secmod.db" == std::string(ent->name)) {
dbFileExists = true;
break;
}
}
- closedir(dir);
+ (void)PR_CloseDir(dir);
return dbFileExists;
}