summaryrefslogtreecommitdiffstats
path: root/searchcore
diff options
context:
space:
mode:
authorTor Egge <Tor.Egge@online.no>2022-06-23 21:39:48 +0200
committerTor Egge <Tor.Egge@online.no>2022-06-23 21:39:48 +0200
commit09d546dfdd152ce4e69971fc8ce422d998cb523a (patch)
tree18da6c3d44a2a056fcc41a213f47feec26f2e30b /searchcore
parent316b44c13d886ef9ff50b040f4a01f38dfd3f94c (diff)
Use std::filesystem to create and remove directories.
Diffstat (limited to 'searchcore')
-rw-r--r--searchcore/src/apps/tests/persistenceconformance_test.cpp2
-rw-r--r--searchcore/src/tests/proton/docsummary/docsummary.cpp19
-rw-r--r--searchcore/src/tests/proton/index/diskindexcleaner_test.cpp7
-rw-r--r--searchcore/src/tests/proton/index/fusionrunner_test.cpp7
-rw-r--r--searchcore/src/tests/proton/index/indexmanager_test.cpp2
-rw-r--r--searchcore/src/vespa/searchcore/proton/attribute/flushableattribute.cpp1
-rw-r--r--searchcore/src/vespa/searchcore/proton/documentmetastore/documentmetastoreflushtarget.cpp1
-rw-r--r--searchcore/src/vespa/searchcore/proton/server/fileconfigmanager.cpp2
-rw-r--r--searchcore/src/vespa/searchcorespi/index/fusionrunner.cpp1
-rw-r--r--searchcore/src/vespa/searchcorespi/index/indexmaintainer.cpp4
10 files changed, 22 insertions, 24 deletions
diff --git a/searchcore/src/apps/tests/persistenceconformance_test.cpp b/searchcore/src/apps/tests/persistenceconformance_test.cpp
index b489a07bba2..a9c18d4b8a9 100644
--- a/searchcore/src/apps/tests/persistenceconformance_test.cpp
+++ b/searchcore/src/apps/tests/persistenceconformance_test.cpp
@@ -379,7 +379,7 @@ public:
}
void clear() override {
- FastOS_FileInterface::EmptyAndRemoveDirectory(_baseDir.c_str());
+ std::filesystem::remove_all(std::filesystem::path(_baseDir));
}
bool hasPersistence() const override { return true; }
diff --git a/searchcore/src/tests/proton/docsummary/docsummary.cpp b/searchcore/src/tests/proton/docsummary/docsummary.cpp
index a0400661b4e..49fd82c3a36 100644
--- a/searchcore/src/tests/proton/docsummary/docsummary.cpp
+++ b/searchcore/src/tests/proton/docsummary/docsummary.cpp
@@ -42,6 +42,7 @@
#include <vespa/vespalib/testkit/testapp.h>
#include <vespa/vespalib/util/destructor_callbacks.h>
#include <vespa/vespalib/util/size_literals.h>
+#include <filesystem>
#include <regex>
#include <vespa/log/log.h>
@@ -82,11 +83,11 @@ public:
DirMaker(const vespalib::string & dir) :
_dir(dir)
{
- FastOS_File::MakeDirectory(dir.c_str());
+ std::filesystem::create_directory(std::filesystem::path(dir));
}
~DirMaker()
{
- FastOS_File::EmptyAndRemoveDirectory(_dir.c_str());
+ std::filesystem::remove_all(std::filesystem::path(_dir));
}
private:
vespalib::string _dir;
@@ -180,7 +181,7 @@ public:
vespalib::ThreadStackExecutor _summaryExecutor;
MockSharedThreadingService _shared_service;
TransLogServer _tls;
- bool _mkdirOk;
+ bool _made_dir;
matching::QueryLimiter _queryLimiter;
DummyWireService _dummy;
::config::DirSpec _spec;
@@ -199,7 +200,7 @@ public:
_summaryExecutor(8, 128_Ki),
_shared_service(_summaryExecutor, _summaryExecutor),
_tls(_shared_service.transport(), "tmp", 9013, ".", _fileHeaderContext),
- _mkdirOk(FastOS_File::MakeDirectory("tmpdb")),
+ _made_dir(std::filesystem::create_directory(std::filesystem::path("tmpdb"))),
_queryLimiter(),
_dummy(),
_spec(TEST_PATH("")),
@@ -212,7 +213,7 @@ public:
_aw(),
_sa()
{
- assert(_mkdirOk);
+ (void) _made_dir;
auto b = std::make_shared<BootstrapConfig>(1, _documenttypesConfig, _repo,
std::make_shared<ProtonConfig>(),
std::make_shared<FiledistributorrpcConfig>(),
@@ -220,9 +221,7 @@ public:
_tuneFileDocumentDB, _hwInfo);
_configMgr.forwardConfig(b);
_configMgr.nextGeneration(_shared_service.transport(), 0ms);
- if (! FastOS_File::MakeDirectory((std::string("tmpdb/") + docTypeName).c_str())) {
- LOG_ABORT("should not be reached");
- }
+ std::filesystem::create_directory(std::filesystem::path(std::string("tmpdb/") + docTypeName));
_ddb = DocumentDB::create("tmpdb", _configMgr.getConfig(), "tcp/localhost:9013", _queryLimiter,
DocTypeName(docTypeName), makeBucketSpace(), *b->getProtonConfigSP(), *this,
_shared_service, _tls, _dummy, _fileHeaderContext,
@@ -239,8 +238,8 @@ public:
_sa.reset();
_aw.reset();
_ddb.reset();
- FastOS_File::EmptyAndRemoveDirectory("tmp");
- FastOS_File::EmptyAndRemoveDirectory("tmpdb");
+ std::filesystem::remove_all(std::filesystem::path("tmp"));
+ std::filesystem::remove_all(std::filesystem::path("tmpdb"));
}
void
diff --git a/searchcore/src/tests/proton/index/diskindexcleaner_test.cpp b/searchcore/src/tests/proton/index/diskindexcleaner_test.cpp
index c814bdf3f37..35583ea46da 100644
--- a/searchcore/src/tests/proton/index/diskindexcleaner_test.cpp
+++ b/searchcore/src/tests/proton/index/diskindexcleaner_test.cpp
@@ -6,6 +6,7 @@
#include <vespa/vespalib/testkit/testapp.h>
#include <vespa/fastos/file.h>
#include <algorithm>
+#include <filesystem>
#include <vespa/log/log.h>
LOG_SETUP("diskindexcleaner_test");
@@ -30,7 +31,7 @@ public:
const string index_dir = "diskindexcleaner_test_data";
void removeTestData() {
- FastOS_FileInterface::EmptyAndRemoveDirectory(index_dir.c_str());
+ std::filesystem::remove_all(std::filesystem::path(index_dir));
}
int
@@ -52,9 +53,9 @@ Test::Main()
}
void createIndex(const string &name) {
- FastOS_FileInterface::MakeDirIfNotPresentOrExit(index_dir.c_str());
+ std::filesystem::create_directory(std::filesystem::path(index_dir));
const string dir_name = index_dir + "/" + name;
- FastOS_FileInterface::MakeDirIfNotPresentOrExit(dir_name.c_str());
+ std::filesystem::create_directory(std::filesystem::path(dir_name));
const string serial_file = dir_name + "/serial.dat";
FastOS_File file(serial_file.c_str());
file.OpenWriteOnlyTruncate();
diff --git a/searchcore/src/tests/proton/index/fusionrunner_test.cpp b/searchcore/src/tests/proton/index/fusionrunner_test.cpp
index 4a84e3972ad..850f8a8f0d1 100644
--- a/searchcore/src/tests/proton/index/fusionrunner_test.cpp
+++ b/searchcore/src/tests/proton/index/fusionrunner_test.cpp
@@ -20,6 +20,7 @@
#include <vespa/vespalib/util/size_literals.h>
#include <vespa/vespalib/stllike/asciistream.h>
#include <vespa/fastos/file.h>
+#include <filesystem>
#include <set>
using document::Document;
@@ -134,7 +135,7 @@ Schema getSchema() {
}
void Test::setUp() {
- FastOS_FileInterface::EmptyAndRemoveDirectory(base_dir.c_str());
+ std::filesystem::remove_all(std::filesystem::path(base_dir));
_fusion_runner.reset(new FusionRunner(base_dir, getSchema(),
TuneFileAttributes(),
_fileHeaderContext));
@@ -144,7 +145,7 @@ void Test::setUp() {
}
void Test::tearDown() {
- FastOS_FileInterface::EmptyAndRemoveDirectory(base_dir.c_str());
+ std::filesystem::remove_all(std::filesystem::path(base_dir));
_selector.reset(0);
}
@@ -167,7 +168,7 @@ void addDocument(DocBuilder & doc_builder, MemoryIndex &index, ISourceSelector &
}
void Test::createIndex(const string &dir, uint32_t id, bool fusion) {
- FastOS_FileInterface::MakeDirIfNotPresentOrExit(dir.c_str());
+ std::filesystem::create_directory(std::filesystem::path(dir));
vespalib::asciistream ost;
if (fusion) {
ost << dir << "/index.fusion." << id;
diff --git a/searchcore/src/tests/proton/index/indexmanager_test.cpp b/searchcore/src/tests/proton/index/indexmanager_test.cpp
index 0bc11e64df8..b427daa4ad1 100644
--- a/searchcore/src/tests/proton/index/indexmanager_test.cpp
+++ b/searchcore/src/tests/proton/index/indexmanager_test.cpp
@@ -85,7 +85,7 @@ Schema getSchema() {
}
void removeTestData() {
- FastOS_FileInterface::EmptyAndRemoveDirectory(index_dir.c_str());
+ std::filesystem::remove_all(std::filesystem::path(index_dir));
}
Document::UP buildDocument(DocBuilder &doc_builder, int id,
diff --git a/searchcore/src/vespa/searchcore/proton/attribute/flushableattribute.cpp b/searchcore/src/vespa/searchcore/proton/attribute/flushableattribute.cpp
index f0e7cad5758..25d6e3c36a7 100644
--- a/searchcore/src/vespa/searchcore/proton/attribute/flushableattribute.cpp
+++ b/searchcore/src/vespa/searchcore/proton/attribute/flushableattribute.cpp
@@ -5,7 +5,6 @@
#include "attribute_directory.h"
#include <vespa/searchlib/attribute/attributefilesavetarget.h>
#include <vespa/searchlib/attribute/attributesaver.h>
-#include <vespa/searchlib/util/dirtraverse.h>
#include <vespa/searchlib/util/filekit.h>
#include <vespa/vespalib/io/fileutil.h>
#include <vespa/searchlib/common/serialnumfileheadercontext.h>
diff --git a/searchcore/src/vespa/searchcore/proton/documentmetastore/documentmetastoreflushtarget.cpp b/searchcore/src/vespa/searchcore/proton/documentmetastore/documentmetastoreflushtarget.cpp
index 53535cddcdf..7786ead49b2 100644
--- a/searchcore/src/vespa/searchcore/proton/documentmetastore/documentmetastoreflushtarget.cpp
+++ b/searchcore/src/vespa/searchcore/proton/documentmetastore/documentmetastoreflushtarget.cpp
@@ -8,7 +8,6 @@
#include <vespa/searchlib/attribute/attributefilesavetarget.h>
#include <vespa/searchlib/attribute/attributememorysavetarget.h>
#include <vespa/searchlib/attribute/attributesaver.h>
-#include <vespa/searchlib/util/dirtraverse.h>
#include <vespa/searchlib/common/serialnumfileheadercontext.h>
#include <vespa/searchlib/util/filekit.h>
#include <filesystem>
diff --git a/searchcore/src/vespa/searchcore/proton/server/fileconfigmanager.cpp b/searchcore/src/vespa/searchcore/proton/server/fileconfigmanager.cpp
index 2c758ee712f..820e61bc7a7 100644
--- a/searchcore/src/vespa/searchcore/proton/server/fileconfigmanager.cpp
+++ b/searchcore/src/vespa/searchcore/proton/server/fileconfigmanager.cpp
@@ -389,7 +389,7 @@ FileConfigManager::removeInvalid()
vespalib::string snapDirBaseName(makeSnapDirBaseName(serial));
vespalib::string snapDir(_baseDir + "/" + snapDirBaseName);
try {
- FastOS_FileInterface::EmptyAndRemoveDirectory(snapDir.c_str());
+ std::filesystem::remove_all(std::filesystem::path(snapDir));
} catch (const std::exception &e) {
LOG(warning, "Removing obsolete config directory '%s' failed due to %s", snapDir.c_str(), e.what());
}
diff --git a/searchcore/src/vespa/searchcorespi/index/fusionrunner.cpp b/searchcore/src/vespa/searchcorespi/index/fusionrunner.cpp
index 1675b6091cf..1d63e883245 100644
--- a/searchcore/src/vespa/searchcorespi/index/fusionrunner.cpp
+++ b/searchcore/src/vespa/searchcorespi/index/fusionrunner.cpp
@@ -6,7 +6,6 @@
#include <vespa/searchlib/common/serialnumfileheadercontext.h>
#include <vespa/searchlib/attribute/fixedsourceselector.h>
#include <vespa/searchlib/queryeval/isourceselector.h>
-#include <vespa/searchlib/util/dirtraverse.h>
#include <vespa/log/log.h>
LOG_SETUP(".searchcorespi.index.fusionrunner");
diff --git a/searchcore/src/vespa/searchcorespi/index/indexmaintainer.cpp b/searchcore/src/vespa/searchcorespi/index/indexmaintainer.cpp
index af273bc5e45..1f022b1215b 100644
--- a/searchcore/src/vespa/searchcorespi/index/indexmaintainer.cpp
+++ b/searchcore/src/vespa/searchcorespi/index/indexmaintainer.cpp
@@ -13,7 +13,6 @@
#include <vespa/searchcorespi/flush/lambdaflushtask.h>
#include <vespa/searchlib/common/i_flush_token.h>
#include <vespa/searchlib/index/schemautil.h>
-#include <vespa/searchlib/util/dirtraverse.h>
#include <vespa/searchlib/util/filekit.h>
#include <vespa/vespalib/io/fileutil.h>
#include <vespa/vespalib/util/array.hpp>
@@ -23,6 +22,7 @@
#include <vespa/vespalib/util/destructor_callbacks.h>
#include <vespa/vespalib/util/time.h>
#include <vespa/fastos/file.h>
+#include <filesystem>
#include <sstream>
#include <vespa/log/log.h>
@@ -1103,7 +1103,7 @@ IndexMaintainer::runFusion(const FusionSpec &fusion_spec, std::shared_ptr<search
} else {
LOG(error, "Fusion failed, fusion dir \"%s\".", fail_dir.c_str());
}
- FastOS_FileInterface::EmptyAndRemoveDirectory(fail_dir.c_str());
+ std::filesystem::remove_all(std::filesystem::path(fail_dir));
{
LockGuard slock(_state_lock);
LockGuard ilock(_index_update_lock);