From 914317d3db05758483eaea09a60ef8bfa3981948 Mon Sep 17 00:00:00 2001 From: Tor Egge Date: Thu, 2 Jun 2022 16:35:21 +0200 Subject: Remove most use of vespalib::rmdir in searchcore. --- searchcore/src/apps/proton/proton.cpp | 4 ++-- .../src/apps/tests/persistenceconformance_test.cpp | 6 ++--- .../src/apps/vespa-feed-bm/vespa_feed_bm.cpp | 6 ++--- .../vespa_redistribute_bm.cpp | 6 ++--- .../tests/index/disk_indexes/disk_indexes_test.cpp | 8 +++---- .../attribute_directory_test.cpp | 27 ++++++++++------------ .../tests/proton/attribute/attributeflush_test.cpp | 10 ++++---- .../documentdb/configurer/configurer_test.cpp | 12 +++++----- .../tests/proton/documentdb/documentdb_test.cpp | 11 +++++---- .../documentdb/feedhandler/feedhandler_test.cpp | 4 ++-- .../src/tests/proton/index/indexmanager_test.cpp | 4 ++-- .../proton_disk_layout/proton_disk_layout_test.cpp | 7 +++--- .../src/vespa/searchcore/bmcluster/bm_cluster.cpp | 4 ++-- .../src/vespa/searchcore/bmcluster/bm_node.cpp | 6 ++--- .../proton/attribute/attribute_directory.cpp | 7 +++--- .../proton/attribute/attributedisklayout.cpp | 3 ++- .../proton/attribute/flushableattribute.cpp | 3 ++- .../docsummary/summarymanagerinitializer.cpp | 4 ++-- .../documentmetastoreflushtarget.cpp | 4 ++-- .../documentmetastoreinitializer.cpp | 4 ++-- .../proton/index/index_manager_initializer.cpp | 3 ++- .../proton/server/bootstrapconfigmanager.cpp | 4 ++-- .../searchcore/proton/server/fileconfigmanager.cpp | 7 +++--- .../src/vespa/searchcore/proton/server/proton.cpp | 2 +- .../proton/server/proton_disk_layout.cpp | 7 +++--- .../searchcore/proton/server/storeonlydocsubdb.cpp | 3 ++- .../vespa/searchcorespi/index/diskindexcleaner.cpp | 3 ++- 27 files changed, 88 insertions(+), 81 deletions(-) diff --git a/searchcore/src/apps/proton/proton.cpp b/searchcore/src/apps/proton/proton.cpp index 386ceb4eeda..2f69bcece66 100644 --- a/searchcore/src/apps/proton/proton.cpp +++ b/searchcore/src/apps/proton/proton.cpp @@ -6,13 +6,13 @@ #include #include #include -#include #include #include #include #include #include #include +#include #include #include #include @@ -239,7 +239,7 @@ App::startAndRun(FastOS_ThreadPool & threadPool, FNET_Transport & transport, int } else { const ProtonConfig &protonConfig = configSnapshot->getProtonConfig(); vespalib::string basedir = protonConfig.basedir; - vespalib::mkdir(basedir, true); + std::filesystem::create_directories(std::filesystem::path(basedir)); { ExitOnSignal exit_on_signal; proton.init(configSnapshot); diff --git a/searchcore/src/apps/tests/persistenceconformance_test.cpp b/searchcore/src/apps/tests/persistenceconformance_test.cpp index 64db35b7acb..b489a07bba2 100644 --- a/searchcore/src/apps/tests/persistenceconformance_test.cpp +++ b/searchcore/src/apps/tests/persistenceconformance_test.cpp @@ -38,8 +38,8 @@ #include #include #include -#include #include +#include #include LOG_SETUP("persistenceconformance_test"); @@ -190,8 +190,8 @@ public: const DocTypeName &docType, const ConfigFactory &factory) { DocumentDBConfig::SP snapshot = factory.create(docType); - vespalib::mkdir(_baseDir, false); - vespalib::mkdir(_baseDir + "/" + docType.toString(), false); + std::filesystem::create_directory(std::filesystem::path(_baseDir)); + std::filesystem::create_directory(std::filesystem::path(_baseDir + "/" + docType.toString())); vespalib::string inputCfg = _baseDir + "/" + docType.toString() + "/baseconfig"; { FileConfigManager fileCfg(_shared_service.transport(), inputCfg, "", docType.getName()); diff --git a/searchcore/src/apps/vespa-feed-bm/vespa_feed_bm.cpp b/searchcore/src/apps/vespa-feed-bm/vespa_feed_bm.cpp index 9a4922c42fc..df0827e78c9 100644 --- a/searchcore/src/apps/vespa-feed-bm/vespa_feed_bm.cpp +++ b/searchcore/src/apps/vespa-feed-bm/vespa_feed_bm.cpp @@ -20,12 +20,12 @@ #include #include #include -#include #include #include #include #include #include +#include #include #include #include @@ -391,7 +391,7 @@ App::main(int argc, char **argv) usage(); return 1; } - vespalib::rmdir(base_dir, true); + std::filesystem::remove_all(std::filesystem::path(base_dir)); Benchmark bm(_bm_params); bm.run(); return 0; @@ -402,6 +402,6 @@ int main(int argc, char **argv) { DummyFileHeaderContext::setCreator("vespa-feed-bm"); App app; auto exit_value = app.main(argc, argv); - vespalib::rmdir(base_dir, true); + std::filesystem::remove_all(std::filesystem::path(base_dir)); return exit_value; } diff --git a/searchcore/src/apps/vespa-redistribute-bm/vespa_redistribute_bm.cpp b/searchcore/src/apps/vespa-redistribute-bm/vespa_redistribute_bm.cpp index 40847baa719..f22e817b72c 100644 --- a/searchcore/src/apps/vespa-redistribute-bm/vespa_redistribute_bm.cpp +++ b/searchcore/src/apps/vespa-redistribute-bm/vespa_redistribute_bm.cpp @@ -22,13 +22,13 @@ #include #include #include -#include #include #include #include #include #include #include +#include #include #include #include @@ -670,7 +670,7 @@ App::main(int argc, char **argv) usage(); return 1; } - vespalib::rmdir(base_dir, true); + std::filesystem::remove_all(std::filesystem::path(base_dir)); Benchmark bm(_bm_params); bm.run(); return 0; @@ -681,6 +681,6 @@ int main(int argc, char **argv) { DummyFileHeaderContext::setCreator("vespa-redistribute-bm"); App app; auto exit_value = app.main(argc, argv); - vespalib::rmdir(base_dir, true); + std::filesystem::remove_all(std::filesystem::path(base_dir)); return exit_value; } diff --git a/searchcore/src/tests/index/disk_indexes/disk_indexes_test.cpp b/searchcore/src/tests/index/disk_indexes/disk_indexes_test.cpp index d22ad499316..6151fcaf1ca 100644 --- a/searchcore/src/tests/index/disk_indexes/disk_indexes_test.cpp +++ b/searchcore/src/tests/index/disk_indexes/disk_indexes_test.cpp @@ -3,9 +3,9 @@ #include #include #include -#include #include #include +#include #include namespace { @@ -149,7 +149,7 @@ TEST_F(DiskIndexesTest, get_transient_size_during_ongoing_fusion) assert_transient_size(0, fusion1); } auto dir = base_dir + "/index.fusion.2"; - vespalib::mkdir(dir, true); + std::filesystem::create_directories(std::filesystem::path(dir)); { /* * Fusion started, but no files written yet. @@ -188,9 +188,9 @@ TEST_F(DiskIndexesTest, get_transient_size_during_ongoing_fusion) int main(int argc, char* argv[]) { - vespalib::rmdir(base_dir, true); + std::filesystem::remove_all(std::filesystem::path(base_dir)); ::testing::InitGoogleTest(&argc, argv); auto result = RUN_ALL_TESTS(); - vespalib::rmdir(base_dir, true); + std::filesystem::remove_all(std::filesystem::path(base_dir)); return result; } diff --git a/searchcore/src/tests/proton/attribute/attribute_directory/attribute_directory_test.cpp b/searchcore/src/tests/proton/attribute/attribute_directory/attribute_directory_test.cpp index ee2904d736c..55de4caed80 100644 --- a/searchcore/src/tests/proton/attribute/attribute_directory/attribute_directory_test.cpp +++ b/searchcore/src/tests/proton/attribute/attribute_directory/attribute_directory_test.cpp @@ -3,10 +3,10 @@ #include #include #include -#include #include #include #include +#include #include LOG_SETUP("attribute_directory_test"); @@ -65,9 +65,7 @@ struct Fixture : public DirectoryHandler vespalib::string getAttrDir(const vespalib::string &name) { return getDir() + "/" + name; } void assertDiskDir(const vespalib::string &name) { - auto fileinfo = vespalib::stat(name); - EXPECT_TRUE(static_cast(fileinfo)); - EXPECT_TRUE(fileinfo->_directory); + EXPECT_TRUE(std::filesystem::is_directory(std::filesystem::path(name))); } void assertAttributeDiskDir(const vespalib::string &name) { @@ -75,8 +73,7 @@ struct Fixture : public DirectoryHandler } void assertNotDiskDir(const vespalib::string &name) { - auto fileinfo = vespalib::stat(name); - EXPECT_FALSE(static_cast(fileinfo)); + EXPECT_FALSE(std::filesystem::exists(std::filesystem::path(name))); } void assertNotAttributeDiskDir(const vespalib::string &name) { @@ -137,7 +134,7 @@ struct Fixture : public DirectoryHandler EXPECT_TRUE(hasAttributeDir(dir)); auto writer = dir->getWriter(); writer->createInvalidSnapshot(serialNum); - vespalib::mkdir(writer->getSnapshotDir(serialNum), false); + std::filesystem::create_directory(std::filesystem::path(writer->getSnapshotDir(serialNum))); writer->markValidSnapshot(serialNum); TEST_DO(assertAttributeDiskDir("foo")); } @@ -163,7 +160,7 @@ struct Fixture : public DirectoryHandler auto dir = createFooAttrDir(); auto writer = dir->getWriter(); writer->createInvalidSnapshot(serialNum); - vespalib::mkdir(writer->getSnapshotDir(serialNum), false); + std::filesystem::create_directory(std::filesystem::path(writer->getSnapshotDir(serialNum))); writer->markValidSnapshot(serialNum); } @@ -210,10 +207,10 @@ TEST_F("Test that we can prune attribute snapshots", Fixture) TEST_DO(f.assertNotAttributeDiskDir("foo")); auto writer = dir->getWriter(); writer->createInvalidSnapshot(2); - vespalib::mkdir(writer->getSnapshotDir(2), false); + std::filesystem::create_directory(std::filesystem::path(writer->getSnapshotDir(2))); writer->markValidSnapshot(2); writer->createInvalidSnapshot(4); - vespalib::mkdir(writer->getSnapshotDir(4), false); + std::filesystem::create_directory(std::filesystem::path(writer->getSnapshotDir(4))); writer->markValidSnapshot(4); writer.reset(); TEST_DO(f.assertAttributeDiskDir("foo")); @@ -264,9 +261,9 @@ TEST_F("Test that attribute directory is not removed due to pruning but disk dir TEST("Test that initial state tracks disk layout") { - vespalib::mkdir("attributes"); - vespalib::mkdir("attributes/foo"); - vespalib::mkdir("attributes/bar"); + std::filesystem::create_directory(std::filesystem::path("attributes")); + std::filesystem::create_directory(std::filesystem::path("attributes/foo")); + std::filesystem::create_directory(std::filesystem::path("attributes/bar")); IndexMetaInfo fooInfo("attributes/foo"); IndexMetaInfo barInfo("attributes/bar"); fooInfo.addSnapshot({true, 4, "snapshot-4"}); @@ -292,8 +289,8 @@ TEST("Test that initial state tracks disk layout") TEST_F("Test that snapshot removal removes correct snapshot directory", Fixture) { TEST_DO(f.setupFooSnapshots(5)); - vespalib::mkdir(f.getSnapshotDir("foo", 5)); - vespalib::mkdir(f.getSnapshotDir("foo", 6)); + std::filesystem::create_directory(std::filesystem::path(f.getSnapshotDir("foo", 5))); + std::filesystem::create_directory(std::filesystem::path(f.getSnapshotDir("foo", 6))); TEST_DO(f.assertSnapshotDir("foo", 5)); TEST_DO(f.assertSnapshotDir("foo", 6)); TEST_DO(f.invalidateFooSnapshots(false)); diff --git a/searchcore/src/tests/proton/attribute/attributeflush_test.cpp b/searchcore/src/tests/proton/attribute/attributeflush_test.cpp index ab7a0db5e7b..6d581f6e6f9 100644 --- a/searchcore/src/tests/proton/attribute/attributeflush_test.cpp +++ b/searchcore/src/tests/proton/attribute/attributeflush_test.cpp @@ -15,13 +15,13 @@ #include #include #include -#include #include #include #include #include #include #include +#include #include #include @@ -436,9 +436,9 @@ Test::requireThatCleanUpIsPerformedAfterFlush() std::string base = "flush/a6"; std::string snap10 = "flush/a6/snapshot-10"; std::string snap20 = "flush/a6/snapshot-20"; - vespalib::mkdir(base, false); - vespalib::mkdir(snap10, false); - vespalib::mkdir(snap20, false); + std::filesystem::create_directory(std::filesystem::path(base)); + std::filesystem::create_directory(std::filesystem::path(snap10)); + std::filesystem::create_directory(std::filesystem::path(snap20)); IndexMetaInfo info("flush/a6"); info.addSnapshot(IndexMetaInfo::Snapshot(true, 10, "snapshot-10")); info.addSnapshot(IndexMetaInfo::Snapshot(false, 20, "snapshot-20")); @@ -662,7 +662,7 @@ Test::Main() if (_argc > 0) { DummyFileHeaderContext::setCreator(_argv[0]); } - vespalib::rmdir(test_dir, true); + std::filesystem::remove_all(std::filesystem::path(test_dir)); TEST_DO(requireThatUpdaterAndFlusherCanRunConcurrently()); TEST_DO(requireThatFlushableAttributeReportsMemoryUsage()); TEST_DO(requireThatFlushableAttributeManagesSyncTokenInfo()); diff --git a/searchcore/src/tests/proton/documentdb/configurer/configurer_test.cpp b/searchcore/src/tests/proton/documentdb/configurer/configurer_test.cpp index 948c9cfe25e..b57ff052e82 100644 --- a/searchcore/src/tests/proton/documentdb/configurer/configurer_test.cpp +++ b/searchcore/src/tests/proton/documentdb/configurer/configurer_test.cpp @@ -26,10 +26,10 @@ #include #include #include -#include #include #include #include +#include using namespace config; using namespace document; @@ -173,8 +173,8 @@ Fixture::Fixture() _resolver(), _configurer() { - vespalib::rmdir(BASE_DIR, true); - vespalib::mkdir(BASE_DIR); + std::filesystem::remove_all(std::filesystem::path(BASE_DIR)); + std::filesystem::create_directory(std::filesystem::path(BASE_DIR)); initViewSet(_views); _configurer = std::make_unique(_views._summaryMgr, _views.searchView, _views.feedView, _queryLimiter, _constantValueRepo, _clock.clock(), "test", 0); @@ -284,8 +284,8 @@ struct FastAccessFixture _view(_service.write()), _configurer(_view._feedView, std::make_unique(), "test") { - vespalib::rmdir(BASE_DIR, true); - vespalib::mkdir(BASE_DIR); + std::filesystem::remove_all(std::filesystem::path(BASE_DIR)); + std::filesystem::create_directory(std::filesystem::path(BASE_DIR)); } ~FastAccessFixture() { _service.shutdown(); @@ -692,5 +692,5 @@ TEST("require that subdbs should change if relevant config changed") TEST_MAIN() { TEST_RUN_ALL(); - vespalib::rmdir(BASE_DIR, true); + std::filesystem::remove_all(std::filesystem::path(BASE_DIR)); } diff --git a/searchcore/src/tests/proton/documentdb/documentdb_test.cpp b/searchcore/src/tests/proton/documentdb/documentdb_test.cpp index a9f923833e5..916f3106923 100644 --- a/searchcore/src/tests/proton/documentdb/documentdb_test.cpp +++ b/searchcore/src/tests/proton/documentdb/documentdb_test.cpp @@ -36,6 +36,7 @@ #include #include #include +#include #include using namespace cloud::config::filedistribution; @@ -62,10 +63,10 @@ namespace { void cleanup_dirs(bool file_config) { - vespalib::rmdir("typea", true); - vespalib::rmdir("tmp", true); + std::filesystem::remove_all(std::filesystem::path("typea")); + std::filesystem::remove_all(std::filesystem::path("tmp")); if (file_config) { - vespalib::rmdir("config", true); + std::filesystem::remove_all(std::filesystem::path("config")); } } @@ -105,7 +106,7 @@ FixtureBase::FixtureBase(bool file_config) : _cleanup(true), _file_config(file_config) { - vespalib::mkdir("typea"); + std::filesystem::create_directory(std::filesystem::path("typea")); } @@ -352,7 +353,7 @@ TEST("require that resume after interrupted save config works") std::cout << "Best config serial is " << best_config_snapshot.syncToken << std::endl; auto old_config_subdir = config_subdir(best_config_snapshot.syncToken); auto new_config_subdir = config_subdir(serialNum + 1); - vespalib::mkdir(new_config_subdir); + std::filesystem::create_directories(std::filesystem::path(new_config_subdir)); auto config_files = vespalib::listDirectory(old_config_subdir); for (auto &config_file : config_files) { vespalib::copy(old_config_subdir + "/" + config_file, new_config_subdir + "/" + config_file, false, false); diff --git a/searchcore/src/tests/proton/documentdb/feedhandler/feedhandler_test.cpp b/searchcore/src/tests/proton/documentdb/feedhandler/feedhandler_test.cpp index 8ef2742b6d8..f9518cb1b5e 100644 --- a/searchcore/src/tests/proton/documentdb/feedhandler/feedhandler_test.cpp +++ b/searchcore/src/tests/proton/documentdb/feedhandler/feedhandler_test.cpp @@ -35,7 +35,7 @@ #include #include #include -#include +#include #include LOG_SETUP("feedhandler_test"); @@ -784,5 +784,5 @@ TEST_MAIN() { DummyFileHeaderContext::setCreator("feedhandler_test"); TEST_RUN_ALL(); - vespalib::rmdir("mytlsdir", true); + std::filesystem::remove_all(std::filesystem::path("mytlsdir")); } diff --git a/searchcore/src/tests/proton/index/indexmanager_test.cpp b/searchcore/src/tests/proton/index/indexmanager_test.cpp index 60864019419..0bc11e64df8 100644 --- a/searchcore/src/tests/proton/index/indexmanager_test.cpp +++ b/searchcore/src/tests/proton/index/indexmanager_test.cpp @@ -19,13 +19,13 @@ #include #include #include -#include #include #include #include #include #include #include +#include #include #include @@ -122,7 +122,7 @@ struct IndexManagerTest : public ::testing::Test { _builder(_schema) { removeTestData(); - vespalib::mkdir(index_dir, false); + std::filesystem::create_directory(std::filesystem::path(index_dir)); resetIndexManager(); } diff --git a/searchcore/src/tests/proton/proton_disk_layout/proton_disk_layout_test.cpp b/searchcore/src/tests/proton/proton_disk_layout/proton_disk_layout_test.cpp index 05d993a33e0..3d087808e44 100644 --- a/searchcore/src/tests/proton/proton_disk_layout/proton_disk_layout_test.cpp +++ b/searchcore/src/tests/proton/proton_disk_layout/proton_disk_layout_test.cpp @@ -10,6 +10,7 @@ #include #include #include +#include using search::index::DummyFileHeaderContext; using search::transactionlog::client::TransLogClient; @@ -25,8 +26,8 @@ static const vespalib::string documentsDir(baseDir + "/documents"); struct FixtureBase { - FixtureBase() { vespalib::rmdir(baseDir, true); } - ~FixtureBase() { vespalib::rmdir(baseDir, true); } + FixtureBase() { std::filesystem::remove_all(std::filesystem::path(baseDir)); } + ~FixtureBase() { std::filesystem::remove_all(std::filesystem::path(baseDir)); } }; struct DiskLayoutFixture { @@ -41,7 +42,7 @@ struct DiskLayoutFixture { void createDirs(const std::set &dirs) { for (const auto &dir : dirs) { - vespalib::mkdir(documentsDir + "/" + dir, false); + std::filesystem::create_directory(std::filesystem::path(documentsDir + "/" + dir)); } } void createDomains(const std::set &domains) { diff --git a/searchcore/src/vespa/searchcore/bmcluster/bm_cluster.cpp b/searchcore/src/vespa/searchcore/bmcluster/bm_cluster.cpp index a5c4fe6851a..123e2b7577d 100644 --- a/searchcore/src/vespa/searchcore/bmcluster/bm_cluster.cpp +++ b/searchcore/src/vespa/searchcore/bmcluster/bm_cluster.cpp @@ -19,9 +19,9 @@ #include #include #include -#include #include #include +#include #include #include @@ -157,7 +157,7 @@ BmCluster::BmCluster(const vespalib::string& base_dir, int base_port, const BmCl { _message_bus_config->add_builders(*_config_set); _rpc_client_config->add_builders(*_config_set); - vespalib::mkdir(_base_dir, false); + std::filesystem::create_directory(std::filesystem::path(_base_dir)); } BmCluster::~BmCluster() diff --git a/searchcore/src/vespa/searchcore/bmcluster/bm_node.cpp b/searchcore/src/vespa/searchcore/bmcluster/bm_node.cpp index 981106f018e..d1910087371 100644 --- a/searchcore/src/vespa/searchcore/bmcluster/bm_node.cpp +++ b/searchcore/src/vespa/searchcore/bmcluster/bm_node.cpp @@ -70,9 +70,9 @@ #include #include #include -#include #include #include +#include #include LOG_SETUP(".bmcluster.bm_node"); @@ -555,8 +555,8 @@ MyBmNode::~MyBmNode() void MyBmNode::create_document_db(const BmClusterParams& params) { - vespalib::mkdir(_base_dir, false); - vespalib::mkdir(_base_dir + "/" + _doc_type_name.getName(), false); + std::filesystem::create_directory(std::filesystem::path(_base_dir)); + std::filesystem::create_directory(std::filesystem::path(_base_dir + "/" + _doc_type_name.getName())); vespalib::string input_cfg = _base_dir + "/" + _doc_type_name.getName() + "/baseconfig"; { proton::FileConfigManager fileCfg(_shared_service.transport(), input_cfg, "", _doc_type_name.getName()); diff --git a/searchcore/src/vespa/searchcore/proton/attribute/attribute_directory.cpp b/searchcore/src/vespa/searchcore/proton/attribute/attribute_directory.cpp index dfd2df18194..8228174d6fd 100644 --- a/searchcore/src/vespa/searchcore/proton/attribute/attribute_directory.cpp +++ b/searchcore/src/vespa/searchcore/proton/attribute/attribute_directory.cpp @@ -6,6 +6,7 @@ #include #include #include +#include #include LOG_SETUP(".proton.attribute.attribute_directory"); @@ -111,7 +112,7 @@ AttributeDirectory::createInvalidSnapshot(SerialNum serialNum) IndexMetaInfo::Snapshot newSnap(false, serialNum, getSnapshotDirComponent(serialNum)); if (empty()) { vespalib::string dirName(getDirName()); - vespalib::mkdir(dirName, false); + std::filesystem::create_directory(std::filesystem::path(dirName)); vespalib::File::sync(vespalib::dirname(dirName)); } { @@ -179,7 +180,7 @@ AttributeDirectory::removeInvalidSnapshots() } for (const auto &serialNum : toRemove) { vespalib::string subDir(getSnapshotDir(serialNum)); - vespalib::rmdir(subDir, true); + std::filesystem::remove_all(std::filesystem::path(subDir)); } if (!toRemove.empty()) { vespalib::File::sync(getDirName()); @@ -198,7 +199,7 @@ AttributeDirectory::removeDiskDir() { if (empty()) { vespalib::string dirName(getDirName()); - vespalib::rmdir(dirName, true); + std::filesystem::remove_all(std::filesystem::path(dirName)); vespalib::File::sync(vespalib::dirname(dirName)); return true; } diff --git a/searchcore/src/vespa/searchcore/proton/attribute/attributedisklayout.cpp b/searchcore/src/vespa/searchcore/proton/attribute/attributedisklayout.cpp index acde52681ad..04e263ae20b 100644 --- a/searchcore/src/vespa/searchcore/proton/attribute/attributedisklayout.cpp +++ b/searchcore/src/vespa/searchcore/proton/attribute/attributedisklayout.cpp @@ -5,6 +5,7 @@ #include #include #include +#include namespace proton { @@ -13,7 +14,7 @@ AttributeDiskLayout::AttributeDiskLayout(const vespalib::string &baseDir, Privat _mutex(), _dirs() { - vespalib::mkdir(_baseDir, false); + std::filesystem::create_directory(std::filesystem::path(_baseDir)); vespalib::File::sync(vespalib::dirname(_baseDir)); } diff --git a/searchcore/src/vespa/searchcore/proton/attribute/flushableattribute.cpp b/searchcore/src/vespa/searchcore/proton/attribute/flushableattribute.cpp index b455d8862b5..f0e7cad5758 100644 --- a/searchcore/src/vespa/searchcore/proton/attribute/flushableattribute.cpp +++ b/searchcore/src/vespa/searchcore/proton/attribute/flushableattribute.cpp @@ -14,6 +14,7 @@ #include #include #include +#include #include #include @@ -79,7 +80,7 @@ FlushableAttribute::Flusher::~Flusher() = default; bool FlushableAttribute::Flusher::saveAttribute() { - vespalib::mkdir(vespalib::dirname(_flushFile), false); + std::filesystem::create_directory(std::filesystem::path(vespalib::dirname(_flushFile))); SerialNumFileHeaderContext fileHeaderContext(_fattr._fileHeaderContext, _syncToken); bool saveSuccess = true; if (_saver && _saver->hasGenerationGuard() && diff --git a/searchcore/src/vespa/searchcore/proton/docsummary/summarymanagerinitializer.cpp b/searchcore/src/vespa/searchcore/proton/docsummary/summarymanagerinitializer.cpp index 568fa740d6f..d949c4a14d3 100644 --- a/searchcore/src/vespa/searchcore/proton/docsummary/summarymanagerinitializer.cpp +++ b/searchcore/src/vespa/searchcore/proton/docsummary/summarymanagerinitializer.cpp @@ -2,7 +2,7 @@ #include "summarymanagerinitializer.h" #include -#include +#include namespace proton { @@ -37,7 +37,7 @@ SummaryManagerInitializer::~SummaryManagerInitializer() = default; void SummaryManagerInitializer::run() { - vespalib::mkdir(_baseDir, false); + std::filesystem::create_directory(std::filesystem::path(_baseDir)); vespalib::Timer timer; EventLogger::loadDocumentStoreStart(_subDbName); *_result = std::make_shared diff --git a/searchcore/src/vespa/searchcore/proton/documentmetastore/documentmetastoreflushtarget.cpp b/searchcore/src/vespa/searchcore/proton/documentmetastore/documentmetastoreflushtarget.cpp index 9f6b1befcdd..53535cddcdf 100644 --- a/searchcore/src/vespa/searchcore/proton/documentmetastore/documentmetastoreflushtarget.cpp +++ b/searchcore/src/vespa/searchcore/proton/documentmetastore/documentmetastoreflushtarget.cpp @@ -11,7 +11,7 @@ #include #include #include -#include +#include #include #include @@ -70,7 +70,7 @@ DocumentMetaStoreFlushTarget::Flusher::~Flusher() = default; bool DocumentMetaStoreFlushTarget::Flusher::saveDocumentMetaStore() { - vespalib::mkdir(_flushDir, false); + std::filesystem::create_directory(std::filesystem::path(_flushDir)); SerialNumFileHeaderContext fileHeaderContext(_dmsft._fileHeaderContext, _syncToken); bool saveSuccess = false; if (_dmsft._hwInfo.disk().slow()) { diff --git a/searchcore/src/vespa/searchcore/proton/documentmetastore/documentmetastoreinitializer.cpp b/searchcore/src/vespa/searchcore/proton/documentmetastore/documentmetastoreinitializer.cpp index ac8f79a7cb2..efc41d2de03 100644 --- a/searchcore/src/vespa/searchcore/proton/documentmetastore/documentmetastoreinitializer.cpp +++ b/searchcore/src/vespa/searchcore/proton/documentmetastore/documentmetastoreinitializer.cpp @@ -4,8 +4,8 @@ #include "documentmetastore.h" #include #include -#include #include +#include using search::GrowStrategy; using search::IndexMetaInfo; @@ -54,7 +54,7 @@ DocumentMetaStoreInitializer::run() EventLogger::loadDocumentMetaStoreComplete(_subDbName, stopWatch.elapsed()); } } else { - vespalib::mkdir(_baseDir, false); + std::filesystem::create_directory(std::filesystem::path(_baseDir)); info.save(); } } diff --git a/searchcore/src/vespa/searchcore/proton/index/index_manager_initializer.cpp b/searchcore/src/vespa/searchcore/proton/index/index_manager_initializer.cpp index 630c536a1ca..6522b8e9209 100644 --- a/searchcore/src/vespa/searchcore/proton/index/index_manager_initializer.cpp +++ b/searchcore/src/vespa/searchcore/proton/index/index_manager_initializer.cpp @@ -2,6 +2,7 @@ #include "index_manager_initializer.h" #include +#include #include LOG_SETUP(".proton.index.indexmanagerinitializer"); @@ -40,7 +41,7 @@ void IndexManagerInitializer::run() { LOG(debug, "About to create proton::IndexManager with %u index field(s)", _schema.getNumIndexFields()); - vespalib::mkdir(_baseDir, false); + std::filesystem::create_directory(std::filesystem::path(_baseDir)); vespalib::File::sync(vespalib::dirname(_baseDir)); *_indexManager = std::make_shared (_baseDir, _indexConfig, _schema, _serialNum, _reconfigurer, _threadingService, diff --git a/searchcore/src/vespa/searchcore/proton/server/bootstrapconfigmanager.cpp b/searchcore/src/vespa/searchcore/proton/server/bootstrapconfigmanager.cpp index f0cb123b49f..c89422e38b1 100644 --- a/searchcore/src/vespa/searchcore/proton/server/bootstrapconfigmanager.cpp +++ b/searchcore/src/vespa/searchcore/proton/server/bootstrapconfigmanager.cpp @@ -7,8 +7,8 @@ #include #include #include -#include #include +#include #include #include @@ -122,7 +122,7 @@ BootstrapConfigManager::update(const ConfigSnapshot & snapshot) const auto &hwCpuCfg = protonConfig.hwinfo.cpu; HwInfoSampler::Config samplerCfg(hwDiskCfg.size, hwDiskCfg.writespeed, hwDiskCfg.slowwritespeedlimit, hwDiskCfg.samplewritesize, hwDiskCfg.shared, hwMemoryCfg.size, hwCpuCfg.cores); - vespalib::mkdir(protonConfig.basedir, true); + std::filesystem::create_directories(std::filesystem::path(protonConfig.basedir)); HwInfoSampler sampler(protonConfig.basedir, samplerCfg); auto newSnapshot(std::make_shared(snapshot.getGeneration(), newDocumenttypesConfig, newRepo, diff --git a/searchcore/src/vespa/searchcore/proton/server/fileconfigmanager.cpp b/searchcore/src/vespa/searchcore/proton/server/fileconfigmanager.cpp index de0d2e65acd..4da09df1297 100644 --- a/searchcore/src/vespa/searchcore/proton/server/fileconfigmanager.cpp +++ b/searchcore/src/vespa/searchcore/proton/server/fileconfigmanager.cpp @@ -19,6 +19,7 @@ #include #include #include +#include #include #include #include @@ -220,7 +221,7 @@ FileConfigManager::FileConfigManager(FNET_Transport & transport, _info(baseDir), _protonConfig() { - vespalib::mkdir(baseDir, false); + std::filesystem::create_directory(std::filesystem::path(baseDir)); vespalib::File::sync(vespalib::dirname(baseDir)); if (!_info.load()) _info.save(); @@ -266,7 +267,7 @@ FileConfigManager::saveConfig(const DocumentDBConfig &snapshot, SerialNum serial bool saveInvalidSnap = _info.save(); assert(saveInvalidSnap); (void) saveInvalidSnap; - vespalib::mkdir(snapDir, false); + std::filesystem::create_directory(std::filesystem::path(snapDir)); save(snapDir, snapshot.getRankProfilesConfig()); save(snapDir, snapshot.getIndexschemaConfig()); save(snapDir, snapshot.getAttributesConfig()); @@ -477,7 +478,7 @@ FileConfigManager::deserializeConfig(SerialNum serialNum, nbostream &stream) bool saveInvalidSnap = _info.save(); assert(saveInvalidSnap); (void) saveInvalidSnap; - vespalib::mkdir(snapDir, false); + std::filesystem::create_directory(std::filesystem::path(snapDir)); } uint32_t numConfigs; diff --git a/searchcore/src/vespa/searchcore/proton/server/proton.cpp b/searchcore/src/vespa/searchcore/proton/server/proton.cpp index fd6f785fa58..871a72de3ca 100644 --- a/searchcore/src/vespa/searchcore/proton/server/proton.cpp +++ b/searchcore/src/vespa/searchcore/proton/server/proton.cpp @@ -601,7 +601,7 @@ Proton::addDocumentDB(const document::DocumentType &docType, } vespalib::string db_dir = config.basedir + "/documents/" + docTypeName.toString(); - vespalib::mkdir(db_dir, false); // Assume parent is created. + std::filesystem::create_directory(std::filesystem::path(db_dir)); // Assume parent is created. auto config_store = std::make_unique(_transport, db_dir + "/config", documentDBConfig->getConfigId(), docTypeName.getName()); config_store->setProtonConfig(bootstrapConfig->getProtonConfigSP()); diff --git a/searchcore/src/vespa/searchcore/proton/server/proton_disk_layout.cpp b/searchcore/src/vespa/searchcore/proton/server/proton_disk_layout.cpp index 0e6318158a2..57a3d21652b 100644 --- a/searchcore/src/vespa/searchcore/proton/server/proton_disk_layout.cpp +++ b/searchcore/src/vespa/searchcore/proton/server/proton_disk_layout.cpp @@ -4,6 +4,7 @@ #include #include #include +#include #include LOG_SETUP(".proton.server.proton_disk_layout"); @@ -70,7 +71,7 @@ ProtonDiskLayout::ProtonDiskLayout(FNET_Transport & transport, const vespalib::s _baseDir(baseDir), _tlsSpec(tlsSpec) { - vespalib::mkdir(getDocumentsDir(_baseDir), true); + std::filesystem::create_directories(std::filesystem::path(getDocumentsDir(_baseDir))); } ProtonDiskLayout::~ProtonDiskLayout() = default; @@ -89,7 +90,7 @@ ProtonDiskLayout::remove(const DocTypeName &docTypeName) LOG(fatal, "Failed to remove tls domain %s", name.c_str()); LOG_ABORT("Failed to remove tls domain"); } - vespalib::rmdir(removedDir, true); + std::filesystem::remove_all(std::filesystem::path(removedDir)); vespalib::File::sync(documentsDir); } @@ -105,7 +106,7 @@ ProtonDiskLayout::initAndPruneUnused(const std::set &docTypeNames) if (dir.second.normal) { vespalib::string name(dir.first.toString()); vespalib::string normalDir(documentsDir + "/" + name); - vespalib::rmdir(normalDir, true); + std::filesystem::remove_all(std::filesystem::path(normalDir)); } remove(dir.first); } else if (docTypeNames.count(dir.first) == 0) { diff --git a/searchcore/src/vespa/searchcore/proton/server/storeonlydocsubdb.cpp b/searchcore/src/vespa/searchcore/proton/server/storeonlydocsubdb.cpp index c3f9bba24e6..d02989a2f8d 100644 --- a/searchcore/src/vespa/searchcore/proton/server/storeonlydocsubdb.cpp +++ b/searchcore/src/vespa/searchcore/proton/server/storeonlydocsubdb.cpp @@ -27,6 +27,7 @@ #include #include #include +#include #include LOG_SETUP(".proton.server.storeonlydocsubdb"); @@ -120,7 +121,7 @@ StoreOnlyDocSubDB::StoreOnlyDocSubDB(const Config &cfg, const Context &ctx) _fileHeaderContext(ctx._fileHeaderContext, _docTypeName, _baseDir), _gidToLidChangeHandler(std::make_shared()) { - vespalib::mkdir(_baseDir, false); // Assume parent is created. + std::filesystem::create_directory(std::filesystem::path(_baseDir)); // Assume parent is created. vespalib::File::sync(vespalib::dirname(_baseDir)); } diff --git a/searchcore/src/vespa/searchcorespi/index/diskindexcleaner.cpp b/searchcore/src/vespa/searchcorespi/index/diskindexcleaner.cpp index 3bed7ea8ea7..704364dfb9b 100644 --- a/searchcore/src/vespa/searchcorespi/index/diskindexcleaner.cpp +++ b/searchcore/src/vespa/searchcorespi/index/diskindexcleaner.cpp @@ -6,6 +6,7 @@ #include "index_disk_dir.h" #include #include +#include #include #include @@ -65,7 +66,7 @@ uint32_t findLastFusionId(const string &base_dir, void removeDir(const string &dir) { LOG(debug, "Removing index dir '%s'", dir.c_str()); invalidateIndex(dir); - vespalib::rmdir(dir, true); + std::filesystem::remove_all(std::filesystem::path(dir)); } bool isOldIndex(const string &index, uint32_t last_fusion_id) { -- cgit v1.2.3