summaryrefslogtreecommitdiffstats
path: root/searchcore
diff options
context:
space:
mode:
authorTor Egge <Tor.Egge@online.no>2023-08-31 11:16:34 +0200
committerTor Egge <Tor.Egge@online.no>2023-08-31 11:16:34 +0200
commitf7b637143e68b41c92ba72fceb0b97ad621d8a41 (patch)
treec376ea1a22250861d8157695b9c19c69c55aca2d /searchcore
parent8ea84bc51e83f76f2b77ba98b49e4d03b0351214 (diff)
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;
}
}
}