aboutsummaryrefslogtreecommitdiffstats
path: root/searchcore
diff options
context:
space:
mode:
authorHenning Baldersheim <balder@yahoo-inc.com>2023-08-31 12:22:25 +0200
committerGitHub <noreply@github.com>2023-08-31 12:22:25 +0200
commit1617e946b55aede314f685ebaa6137e8dbc7bf50 (patch)
treee02195cb46cb22852017e30c7d1d491021f6e4c2 /searchcore
parent36dc76d29defd41b3347bd86fb48016946cd34b2 (diff)
parentf7b637143e68b41c92ba72fceb0b97ad621d8a41 (diff)
Merge pull request #28307 from vespa-engine/toregge/use-std-filesystem-directory-iterator-in-index-read-utilities
Use std::filesystem::directory_iterator in IndexReadUtilities
Diffstat (limited to 'searchcore')
-rw-r--r--searchcore/src/vespa/searchcorespi/index/indexreadutilities.cpp30
1 files changed, 15 insertions, 15 deletions
diff --git a/searchcore/src/vespa/searchcorespi/index/indexreadutilities.cpp b/searchcore/src/vespa/searchcorespi/index/indexreadutilities.cpp
index 14556ddef29..010a3174e1c 100644
--- a/searchcore/src/vespa/searchcorespi/index/indexreadutilities.cpp
+++ b/searchcore/src/vespa/searchcorespi/index/indexreadutilities.cpp
@@ -4,6 +4,7 @@
#include "indexdisklayout.h"
#include <vespa/fastlib/io/bufferedfile.h>
#include <vespa/vespalib/data/fileheader.h>
+#include <filesystem>
#include <set>
#include <vector>
@@ -25,22 +26,21 @@ scanForIndexes(const vespalib::string &baseDir,
std::vector<vespalib::string> &flushDirs,
vespalib::string &fusionDir)
{
- FastOS_DirectoryScan dirScan(baseDir.c_str());
- while (dirScan.ReadNext()) {
- if (!dirScan.IsDirectory()) {
- continue;
- }
- vespalib::string name = dirScan.GetName();
- if (name.find(IndexDiskLayout::FlushDirPrefix) == 0) {
- flushDirs.push_back(name);
- }
- if (name.find(IndexDiskLayout::FusionDirPrefix) == 0) {
- if (!fusionDir.empty()) {
- // Should never happen, since we run cleanup before load.
- LOG(warning, "Base directory '%s' contains multiple fusion indexes",
- baseDir.c_str());
+ std::filesystem::directory_iterator dir_scan{std::filesystem::path(baseDir)};
+ for (auto& entry : dir_scan) {
+ if (entry.is_directory()) {
+ vespalib::string name = entry.path().filename().string();
+ if (name.find(IndexDiskLayout::FlushDirPrefix) == 0) {
+ flushDirs.push_back(name);
+ }
+ if (name.find(IndexDiskLayout::FusionDirPrefix) == 0) {
+ if (!fusionDir.empty()) {
+ // Should never happen, since we run cleanup before load.
+ LOG(warning, "Base directory '%s' contains multiple fusion indexes",
+ baseDir.c_str());
+ }
+ fusionDir = name;
}
- fusionDir = name;
}
}
}