diff options
author | Tor Egge <Tor.Egge@online.no> | 2022-06-02 15:10:46 +0200 |
---|---|---|
committer | Tor Egge <Tor.Egge@online.no> | 2022-06-02 15:10:46 +0200 |
commit | d8db0245a5aad9fbc0568bb11db99d9c5394d1a5 (patch) | |
tree | c05f7bd6065b7c77c7f7c98c0fadb02bbc8f7898 | |
parent | d28745bcca2737bd716fb001a1417cdfb1febd96 (diff) |
Remove most use of vespalib::rmdir in searchlib.
21 files changed, 65 insertions, 71 deletions
diff --git a/searchcore/src/tests/proton/attribute/attribute_initializer/attribute_initializer_test.cpp b/searchcore/src/tests/proton/attribute/attribute_initializer/attribute_initializer_test.cpp index 93cb456cc06..3016815a89c 100644 --- a/searchcore/src/tests/proton/attribute/attribute_initializer/attribute_initializer_test.cpp +++ b/searchcore/src/tests/proton/attribute/attribute_initializer/attribute_initializer_test.cpp @@ -67,7 +67,7 @@ saveAttr(const vespalib::string &name, const Config &cfg, SerialNum serialNum, S auto writer = dir->getWriter(); writer->createInvalidSnapshot(serialNum); auto snapshotdir = writer->getSnapshotDir(serialNum); - vespalib::mkdir(snapshotdir); + std::filesystem::create_directory(std::filesystem::path(snapshotdir)); auto av = search::AttributeFactory::createAttribute(snapshotdir + "/" + name, cfg); av->setCreateSerialNum(createSerialNum); av->addReservedDoc(); @@ -245,6 +245,6 @@ TEST("require that transient memory usage is reported for attribute load without TEST_MAIN() { - vespalib::rmdir(test_dir, true); + std::filesystem::remove_all(std::filesystem::path(test_dir)); TEST_RUN_ALL(); } diff --git a/searchcore/src/tests/proton/attribute/attribute_manager/attribute_manager_test.cpp b/searchcore/src/tests/proton/attribute/attribute_manager/attribute_manager_test.cpp index b446ca367c0..95f0cff088d 100644 --- a/searchcore/src/tests/proton/attribute/attribute_manager/attribute_manager_test.cpp +++ b/searchcore/src/tests/proton/attribute/attribute_manager/attribute_manager_test.cpp @@ -869,6 +869,6 @@ TEST_F("require that shrink flushtarget is handed over to new attribute manager" TEST_MAIN() { - vespalib::rmdir(test_dir, true); + std::filesystem::remove_all(std::filesystem::path(test_dir)); TEST_RUN_ALL(); } diff --git a/searchcore/src/tests/proton/attribute/attribute_populator/attribute_populator_test.cpp b/searchcore/src/tests/proton/attribute/attribute_populator/attribute_populator_test.cpp index 0d09d45c33a..c66b2dd15dc 100644 --- a/searchcore/src/tests/proton/attribute/attribute_populator/attribute_populator_test.cpp +++ b/searchcore/src/tests/proton/attribute/attribute_populator/attribute_populator_test.cpp @@ -115,6 +115,6 @@ TEST_F("require that reprocess with document populates attribute", Fixture) TEST_MAIN() { - vespalib::rmdir(TEST_DIR, true); + std::filesystem::remove_all(std::filesystem::path(TEST_DIR)); TEST_RUN_ALL(); } diff --git a/searchcore/src/tests/proton/common/hw_info_sampler/hw_info_sampler_test.cpp b/searchcore/src/tests/proton/common/hw_info_sampler/hw_info_sampler_test.cpp index b9894f660e1..585a8b38fe1 100644 --- a/searchcore/src/tests/proton/common/hw_info_sampler/hw_info_sampler_test.cpp +++ b/searchcore/src/tests/proton/common/hw_info_sampler/hw_info_sampler_test.cpp @@ -122,6 +122,6 @@ TEST_F("require that num cpu cores can be sampled", Fixture) TEST_MAIN() { - vespalib::rmdir(test_dir, true); + std::filesystem::remove_all(std::filesystem::path(test_dir)); TEST_RUN_ALL(); } diff --git a/searchcore/src/tests/proton/documentdb/document_subdbs/document_subdbs_test.cpp b/searchcore/src/tests/proton/documentdb/document_subdbs/document_subdbs_test.cpp index cb3acdb7ec8..a9a75a1fc7a 100644 --- a/searchcore/src/tests/proton/documentdb/document_subdbs/document_subdbs_test.cpp +++ b/searchcore/src/tests/proton/documentdb/document_subdbs/document_subdbs_test.cpp @@ -64,7 +64,6 @@ using searchcorespi::index::IThreadingService; using storage::spi::Timestamp; using vespa::config::search::core::ProtonConfig; using vespa::config::content::core::BucketspacesConfig; -using vespalib::mkdir; using vespalib::datastore::CompactionStrategy; using proton::index::IndexConfig; diff --git a/searchcore/src/tests/proton/reprocessing/attribute_reprocessing_initializer/attribute_reprocessing_initializer_test.cpp b/searchcore/src/tests/proton/reprocessing/attribute_reprocessing_initializer/attribute_reprocessing_initializer_test.cpp index ebec0841ebf..46796738fa8 100644 --- a/searchcore/src/tests/proton/reprocessing/attribute_reprocessing_initializer/attribute_reprocessing_initializer_test.cpp +++ b/searchcore/src/tests/proton/reprocessing/attribute_reprocessing_initializer/attribute_reprocessing_initializer_test.cpp @@ -307,7 +307,7 @@ TEST(InterruptedTest, require_that_added_attribute_aspect_with_flushed_attribute auto writer = dir->getWriter(); writer->createInvalidSnapshot(INIT_SERIAL_NUM); auto snapshotdir = writer->getSnapshotDir(INIT_SERIAL_NUM); - vespalib::mkdir(snapshotdir); + std::filesystem::create_directory(std::filesystem::path(snapshotdir)); writer->markValidSnapshot(INIT_SERIAL_NUM); auto av = AttributeFactory::createAttribute(snapshotdir + "/a", Config(BasicType::STRING)); diff --git a/searchlib/src/tests/attribute/attribute_test.cpp b/searchlib/src/tests/attribute/attribute_test.cpp index 6f86112a0f2..bb516c3b451 100644 --- a/searchlib/src/tests/attribute/attribute_test.cpp +++ b/searchlib/src/tests/attribute/attribute_test.cpp @@ -20,7 +20,6 @@ #include <vespa/document/update/arithmeticvalueupdate.h> #include <vespa/document/update/assignvalueupdate.h> #include <vespa/document/update/mapvalueupdate.h> -#include <vespa/vespalib/io/fileutil.h> #include <vespa/vespalib/gtest/gtest.h> #include <vespa/vespalib/util/mmap_file_allocator_factory.h> #include <vespa/vespalib/util/round_up_to_page_size.h> @@ -28,6 +27,7 @@ #include <vespa/vespalib/stllike/asciistream.h> #include <vespa/fastos/file.h> #include <cmath> +#include <filesystem> #include <iostream> #include <vespa/log/log.h> @@ -291,7 +291,6 @@ protected: void testPendingCompaction(); void testConditionalCommit(); - static int64_t stat_size(const vespalib::string& swapfile); int test_paged_attribute(const vespalib::string& name, const vespalib::string& swapfile, const search::attribute::Config& cfg); void test_paged_attributes(); @@ -2292,14 +2291,6 @@ AttributeTest::testConditionalCommit() { EXPECT_EQ(0u, iv.getChangeVectorMemoryUsage().usedBytes()); } -int64_t -AttributeTest::stat_size(const vespalib::string& swapfile) -{ - auto stat = vespalib::stat(swapfile); - EXPECT_TRUE(stat); - return stat ? stat->_size : 0u; -} - int AttributeTest::test_paged_attribute(const vespalib::string& name, const vespalib::string& swapfile, const search::attribute::Config& cfg) { @@ -2322,10 +2313,10 @@ AttributeTest::test_paged_attribute(const vespalib::string& name, const vespalib if (failed) { return 0; } - auto size1 = stat_size(swapfile); + auto size1 = std::filesystem::file_size(std::filesystem::path(swapfile)); // Grow mapping from lid to value or multivalue index addClearedDocs(av, lid_mapping_size); - auto size2 = stat_size(swapfile); + auto size2 = std::filesystem::file_size(std::filesystem::path(swapfile)); auto size3 = size2; EXPECT_LT(size1, size2); if (cfg.collectionType().isMultiValue()) { @@ -2337,7 +2328,7 @@ AttributeTest::test_paged_attribute(const vespalib::string& name, const vespalib } av->commit(); } - size3 = stat_size(swapfile); + size3 = std::filesystem::file_size(std::filesystem::path(swapfile)); EXPECT_LT(size2, size3); result += 2; } @@ -2355,7 +2346,7 @@ AttributeTest::test_paged_attribute(const vespalib::string& name, const vespalib } av->commit(); } - auto size4 = stat_size(swapfile); + auto size4 = std::filesystem::file_size(std::filesystem::path(swapfile)); EXPECT_LT(size3, size4); result += 4; } @@ -2385,7 +2376,7 @@ AttributeTest::test_paged_attributes() cfg5.setPaged(true); EXPECT_EQ(1, test_paged_attribute("std-bool-sv-paged", basedir + "/4.std-bool-sv-paged/swapfile", cfg5)); vespalib::alloc::MmapFileAllocatorFactory::instance().setup(""); - vespalib::rmdir(basedir, true); + std::filesystem::remove_all(std::filesystem::path(basedir)); } void testNamePrefix() { @@ -2545,17 +2536,17 @@ TEST_F(AttributeTest, paged_attributes) void deleteDataDirs() { - vespalib::rmdir(tmpDir, true); - vespalib::rmdir(clsDir, true); - vespalib::rmdir(asuDir, true); + std::filesystem::remove_all(std::filesystem::path(tmpDir)); + std::filesystem::remove_all(std::filesystem::path(clsDir)); + std::filesystem::remove_all(std::filesystem::path(asuDir)); } void createDataDirs() { - vespalib::mkdir(tmpDir, true); - vespalib::mkdir(clsDir, true); - vespalib::mkdir(asuDir, true); + std::filesystem::create_directories(std::filesystem::path(tmpDir)); + std::filesystem::create_directories(std::filesystem::path(clsDir)); + std::filesystem::create_directories(std::filesystem::path(asuDir)); } int diff --git a/searchlib/src/tests/attribute/postinglistattribute/postinglistattribute_test.cpp b/searchlib/src/tests/attribute/postinglistattribute/postinglistattribute_test.cpp index 55266841c67..e866c57342e 100644 --- a/searchlib/src/tests/attribute/postinglistattribute/postinglistattribute_test.cpp +++ b/searchlib/src/tests/attribute/postinglistattribute/postinglistattribute_test.cpp @@ -16,10 +16,10 @@ #include <vespa/searchlib/parsequery/parse.h> #include <vespa/searchcommon/attribute/config.h> #include <vespa/vespalib/stllike/asciistream.h> -#include <vespa/vespalib/io/fileutil.h> #include <vespa/vespalib/util/compress.h> #include <vespa/fastos/file.h> #include <vespa/searchlib/attribute/enumstore.hpp> +#include <filesystem> #include <iostream> #include <vespa/log/log.h> @@ -1199,9 +1199,9 @@ int main(int argc, char* argv[]) { ::testing::InitGoogleTest(&argc, argv); - vespalib::rmdir(tmp_dir, true); - vespalib::mkdir(tmp_dir, true); + std::filesystem::remove_all(std::filesystem::path(tmp_dir)); + std::filesystem::create_directories(std::filesystem::path(tmp_dir)); int retval = RUN_ALL_TESTS(); - vespalib::rmdir(tmp_dir, true); + std::filesystem::remove_all(std::filesystem::path(tmp_dir)); return retval; } diff --git a/searchlib/src/tests/attribute/save_target/attribute_save_target_test.cpp b/searchlib/src/tests/attribute/save_target/attribute_save_target_test.cpp index 505032220c1..b774e5c5c2e 100644 --- a/searchlib/src/tests/attribute/save_target/attribute_save_target_test.cpp +++ b/searchlib/src/tests/attribute/save_target/attribute_save_target_test.cpp @@ -60,7 +60,7 @@ public: int exp_value) { vespalib::string file_name = base_file_name + "." + file_suffix; - EXPECT_TRUE(vespalib::fileExists(file_name)); + EXPECT_TRUE(std::filesystem::exists(std::filesystem::path(file_name))); auto loaded = FileUtil::loadFile(file_name); EXPECT_FALSE(loaded->empty()); diff --git a/searchlib/src/tests/attribute/tensorattribute/tensorattribute_test.cpp b/searchlib/src/tests/attribute/tensorattribute/tensorattribute_test.cpp index e8450104963..ee1680bbd9a 100644 --- a/searchlib/src/tests/attribute/tensorattribute/tensorattribute_test.cpp +++ b/searchlib/src/tests/attribute/tensorattribute/tensorattribute_test.cpp @@ -19,7 +19,6 @@ #include <vespa/searchlib/util/fileutil.h> #include <vespa/searchcommon/attribute/config.h> #include <vespa/vespalib/data/fileheader.h> -#include <vespa/vespalib/io/fileutil.h> #include <vespa/vespalib/test/insertion_operators.h> #include <vespa/vespalib/testkit/test_kit.h> #include <vespa/vespalib/util/mmap_file_allocator_factory.h> @@ -31,6 +30,7 @@ #include <vespa/eval/eval/value.h> #include <vespa/eval/eval/test/value_compare.h> #include <vespa/fastos/file.h> +#include <filesystem> #include <vespa/log/log.h> LOG_SETUP("tensorattribute_test"); @@ -561,7 +561,7 @@ Fixture::save_example_tensors_with_mock_index() set_example_tensors(); mock_index().save_index_with_value(123); save(); - EXPECT_TRUE(vespalib::fileExists(_name + ".nnidx")); + EXPECT_TRUE(std::filesystem::exists(std::filesystem::path(_name + ".nnidx"))); } void @@ -817,7 +817,7 @@ TEST_F("Hnsw index is integrated in dense tensor attribute and can be saved and expect_level_0(2, index_a.get_node(1)); expect_level_0(1, index_a.get_node(2)); f.save(); - EXPECT_TRUE(vespalib::fileExists(attr_name + ".nnidx")); + EXPECT_TRUE(std::filesystem::exists(std::filesystem::path(attr_name + ".nnidx"))); f.load(); auto &index_b = f.hnsw_index(); @@ -948,7 +948,7 @@ TEST_F("onLoad() reconstructs nearest neighbor index if save file does not exist { f.set_example_tensors(); f.save(); - EXPECT_FALSE(vespalib::fileExists(attr_name + ".nnidx")); + EXPECT_FALSE(std::filesystem::exists(std::filesystem::path(attr_name + ".nnidx"))); f.load(); // index is reconstructed by adding all loaded tensors auto& index = f.mock_index(); @@ -1146,10 +1146,10 @@ TEST("Dense tensor attribute with paged flag uses mmap file allocator") { Fixture f(vec_2d_spec, FixtureTraits().dense().mmap_file_allocator()); vespalib::string allocator_dir(basedir + "/0.my_attr"); - EXPECT_TRUE(vespalib::isDirectory(allocator_dir)); + EXPECT_TRUE(std::filesystem::is_directory(std::filesystem::path(allocator_dir))); } vespalib::alloc::MmapFileAllocatorFactory::instance().setup(""); - vespalib::rmdir(basedir, true); + std::filesystem::remove_all(std::filesystem::path(basedir)); } TEST_MAIN() { TEST_RUN_ALL(); } diff --git a/searchlib/src/tests/diskindex/bitvector/bitvector_test.cpp b/searchlib/src/tests/diskindex/bitvector/bitvector_test.cpp index 570f1a6ea03..a9f3f91c57e 100644 --- a/searchlib/src/tests/diskindex/bitvector/bitvector_test.cpp +++ b/searchlib/src/tests/diskindex/bitvector/bitvector_test.cpp @@ -6,7 +6,7 @@ #include <vespa/searchlib/diskindex/fieldwriter.h> #include <vespa/searchlib/index/dummyfileheadercontext.h> #include <vespa/searchcommon/common/schema.h> -#include <vespa/vespalib/io/fileutil.h> +#include <filesystem> #include <vespa/log/log.h> LOG_SETUP("bitvector_test"); @@ -50,7 +50,7 @@ FieldWriterWrapper::open(const std::string &path, const TuneFileSeqWrite &tuneFileWrite, const common::FileHeaderContext &fileHeaderContext) { - vespalib::mkdir(path, false); + std::filesystem::create_directory(std::filesystem::path(path)); return _writer.open(path, 64, 10000, false, false, schema, indexId, FieldLengthInfo(), tuneFileWrite, fileHeaderContext); } @@ -105,7 +105,7 @@ Test::requireThatDictionaryHandlesNoEntries(bool directio, bool readmmap) if (readmmap) tuneFileRead.setWantMemoryMap(); FieldWriterWrapper fww(5, 2); - vespalib::mkdir("dump", false); + std::filesystem::create_directory(std::filesystem::path("dump")); EXPECT_TRUE(fww.open("dump/1/", _schema, _indexId, tuneFileWrite, fileHeaderContext)); fww.newWord("1").add(1); diff --git a/searchlib/src/tests/diskindex/diskindex/diskindex_test.cpp b/searchlib/src/tests/diskindex/diskindex/diskindex_test.cpp index 6152d965e32..2e8617b4dcb 100644 --- a/searchlib/src/tests/diskindex/diskindex/diskindex_test.cpp +++ b/searchlib/src/tests/diskindex/diskindex/diskindex_test.cpp @@ -14,7 +14,7 @@ #include <vespa/searchlib/queryeval/fake_requestcontext.h> #include <vespa/searchlib/index/dummyfileheadercontext.h> #include <vespa/searchlib/test/fakedata/fpfactory.h> -#include <vespa/vespalib/io/fileutil.h> +#include <filesystem> #include <iostream> #include <set> @@ -316,7 +316,7 @@ Test::Main() DummyFileHeaderContext::setCreator(_argv[0]); } - vespalib::mkdir("index", false); + std::filesystem::create_directory(std::filesystem::path("index")); TEST_DO(openIndex("index/1fedewe", false, false, true, true, true)); TEST_DO(requireThatLookupIsWorking(true, true, true)); TEST_DO(openIndex("index/1fede", false, false, true, true, false)); diff --git a/searchlib/src/tests/diskindex/fieldwriter/fieldwriter_test.cpp b/searchlib/src/tests/diskindex/fieldwriter/fieldwriter_test.cpp index 47725d7306d..3424343b2fe 100644 --- a/searchlib/src/tests/diskindex/fieldwriter/fieldwriter_test.cpp +++ b/searchlib/src/tests/diskindex/fieldwriter/fieldwriter_test.cpp @@ -13,7 +13,6 @@ #include <vespa/searchlib/index/schemautil.h> #include <vespa/searchlib/test/fakedata/fakeword.h> #include <vespa/searchlib/test/fakedata/fakewordset.h> -#include <vespa/vespalib/io/fileutil.h> #include <vespa/vespalib/stllike/asciistream.h> #include <vespa/vespalib/util/rand48.h> #include <vespa/vespalib/util/size_literals.h> @@ -22,6 +21,7 @@ #include <vespa/fastos/file.h> #include <vespa/vespalib/util/signalhandler.h> #include <unistd.h> +#include <filesystem> #include <vespa/log/log.h> LOG_SETUP("fieldwriter_test"); @@ -702,7 +702,7 @@ FieldWriterTest::main(int argc, char **argv) _wordSet.setupParams(false, false); _wordSet.setupWords(_rnd, _numDocs, _commonDocFreq, _numWordsPerClass); - vespalib::mkdir("index", false); + std::filesystem::create_directory(std::filesystem::path("index")); testFieldWriterVariants(_wordSet, _numDocs, _verbose); _wordSet2.setupParams(false, false); @@ -711,7 +711,7 @@ FieldWriterTest::main(int argc, char **argv) _wordSet2.addDocIdBias(docIdBias); // Large skip numbers testFieldWriterVariantsWithHighLids(_wordSet2, _numDocs + docIdBias, _verbose); - vespalib::rmdir("index", true); + std::filesystem::remove_all(std::filesystem::path("index")); return 0; } diff --git a/searchlib/src/tests/diskindex/fusion/fusion_test.cpp b/searchlib/src/tests/diskindex/fusion/fusion_test.cpp index 37fac07a8d4..6e60d14b8ff 100644 --- a/searchlib/src/tests/diskindex/fusion/fusion_test.cpp +++ b/searchlib/src/tests/diskindex/fusion/fusion_test.cpp @@ -19,12 +19,12 @@ #include <vespa/vespalib/btree/btreenode.hpp> #include <vespa/vespalib/btree/btreenodeallocator.hpp> #include <vespa/vespalib/btree/btreeroot.hpp> -#include <vespa/vespalib/io/fileutil.h> #include <vespa/vespalib/util/gate.h> #include <vespa/vespalib/util/destructor_callbacks.h> #include <vespa/vespalib/util/threadstackexecutor.h> #include <vespa/vespalib/util/sequencedtaskexecutor.h> #include <vespa/vespalib/gtest/gtest.h> +#include <filesystem> #include <vespa/log/log.h> LOG_SETUP("fusion_test"); @@ -542,9 +542,9 @@ namespace { void clean_field_length_testdirs() { - vespalib::rmdir("fldump2", true); - vespalib::rmdir("fldump3", true); - vespalib::rmdir("fldump4", true); + std::filesystem::remove_all(std::filesystem::path("fldump2")); + std::filesystem::remove_all(std::filesystem::path("fldump3")); + std::filesystem::remove_all(std::filesystem::path("fldump4")); } } @@ -593,8 +593,8 @@ namespace { void clean_stopped_fusion_testdirs() { - vespalib::rmdir("stopdump2", true); - vespalib::rmdir("stopdump3", true); + std::filesystem::remove_all(std::filesystem::path("stopdump2")); + std::filesystem::remove_all(std::filesystem::path("stopdump3")); } class MyFlushToken : public FlushToken @@ -631,11 +631,11 @@ TEST_F(FusionTest, require_that_fusion_can_be_stopped) make_simple_index("stopdump2", MockFieldLengthInspector()); ASSERT_TRUE(try_merge_simple_indexes("stopdump3", {"stopdump2"}, flush_token)); EXPECT_EQ(48, flush_token->get_checks()); - vespalib::rmdir("stopdump3", true); + std::filesystem::remove_all(std::filesystem::path("stopdump3")); flush_token = std::make_shared<MyFlushToken>(1); ASSERT_FALSE(try_merge_simple_indexes("stopdump3", {"stopdump2"}, flush_token)); EXPECT_EQ(8, flush_token->get_checks()); - vespalib::rmdir("stopdump3", true); + std::filesystem::remove_all(std::filesystem::path("stopdump3")); flush_token = std::make_shared<MyFlushToken>(47); ASSERT_FALSE(try_merge_simple_indexes("stopdump3", {"stopdump2"}, flush_token)); EXPECT_LE(48, flush_token->get_checks()); diff --git a/searchlib/src/tests/docstore/document_store_visitor/document_store_visitor_test.cpp b/searchlib/src/tests/docstore/document_store_visitor/document_store_visitor_test.cpp index 0658287f29b..1df5f9a1409 100644 --- a/searchlib/src/tests/docstore/document_store_visitor/document_store_visitor_test.cpp +++ b/searchlib/src/tests/docstore/document_store_visitor/document_store_visitor_test.cpp @@ -11,10 +11,10 @@ #include <vespa/document/fieldvalue/stringfieldvalue.h> #include <vespa/document/repo/configbuilder.h> #include <vespa/document/fieldvalue/document.h> -#include <vespa/vespalib/io/fileutil.h> #include <vespa/vespalib/stllike/asciistream.h> #include <vespa/vespalib/util/size_literals.h> #include <vespa/vespalib/util/threadstackexecutor.h> +#include <filesystem> #include <vespa/log/log.h> LOG_SETUP("document_store_visitor_test"); @@ -277,13 +277,13 @@ Fixture::resetDocStore() void Fixture::rmdir() { - vespalib::rmdir(_baseDir, true); + std::filesystem::remove_all(std::filesystem::path(_baseDir)); } void Fixture::mkdir() { - vespalib::mkdir(_baseDir, false); + std::filesystem::create_directory(std::filesystem::path(_baseDir)); } diff --git a/searchlib/src/tests/queryeval/blueprint/intermediate_blueprints_test.cpp b/searchlib/src/tests/queryeval/blueprint/intermediate_blueprints_test.cpp index 45183696dfc..d478adafa57 100644 --- a/searchlib/src/tests/queryeval/blueprint/intermediate_blueprints_test.cpp +++ b/searchlib/src/tests/queryeval/blueprint/intermediate_blueprints_test.cpp @@ -10,10 +10,10 @@ #include <vespa/searchlib/queryeval/andnotsearch.h> #include <vespa/searchlib/queryeval/wand/weak_and_search.h> #include <vespa/searchlib/queryeval/fake_requestcontext.h> -#include <vespa/vespalib/io/fileutil.h> #include <vespa/searchlib/test/diskindex/testdiskindex.h> #include <vespa/searchlib/query/tree/simplequery.h> #include <vespa/searchlib/common/bitvectoriterator.h> +#include <filesystem> #include <vespa/log/log.h> LOG_SETUP("blueprint_test"); @@ -1246,7 +1246,7 @@ makeTerm(const std::string & term) TEST("require that children does not optimize when parents refuse them to") { FakeRequestContext requestContext; search::diskindex::TestDiskIndex index; - vespalib::mkdir("index", false); + std::filesystem::create_directory(std::filesystem::path("index")); index.buildSchema(); index.openIndex("index/1", false, true, false, false, false); FieldSpecBaseList fields; diff --git a/searchlib/src/vespa/searchlib/diskindex/field_merger.cpp b/searchlib/src/vespa/searchlib/diskindex/field_merger.cpp index dfd4d891818..860903174bc 100644 --- a/searchlib/src/vespa/searchlib/diskindex/field_merger.cpp +++ b/searchlib/src/vespa/searchlib/diskindex/field_merger.cpp @@ -17,6 +17,7 @@ #include <vespa/vespalib/io/fileutil.h> #include <vespa/vespalib/stllike/asciistream.h> #include <vespa/vespalib/util/exceptions.h> +#include <filesystem> #include <vespa/log/log.h> @@ -83,7 +84,7 @@ void FieldMerger::make_tmp_dirs() { for (const auto & index : _fusion_out_index.get_old_indexes()) { - vespalib::mkdir(createTmpPath(_field_dir, index.getIndex()), false); + std::filesystem::create_directory(std::filesystem::path(createTmpPath(_field_dir, index.getIndex()))); } } @@ -484,7 +485,7 @@ FieldMerger::merge_field_start() _state = State::MERGE_DONE; return; } - vespalib::mkdir(_field_dir, false); + std::filesystem::create_directory(std::filesystem::path(_field_dir)); LOG(debug, "merge_field for field %s dir %s", _field_name.c_str(), _field_dir.c_str()); diff --git a/searchlib/src/vespa/searchlib/diskindex/fusion.cpp b/searchlib/src/vespa/searchlib/diskindex/fusion.cpp index 41b4b3cb794..e142255252c 100644 --- a/searchlib/src/vespa/searchlib/diskindex/fusion.cpp +++ b/searchlib/src/vespa/searchlib/diskindex/fusion.cpp @@ -14,6 +14,7 @@ #include <vespa/vespalib/util/exceptions.h> #include <vespa/vespalib/util/lambdatask.h> #include <vespa/document/util/queue.h> +#include <filesystem> #include <vespa/log/log.h> @@ -123,7 +124,7 @@ Fusion::merge(vespalib::Executor& shared_executor, std::shared_ptr<IFlushToken> } } - vespalib::mkdir(_fusion_out_index.get_path(), false); + std::filesystem::create_directory(std::filesystem::path(_fusion_out_index.get_path())); _fusion_out_index.get_schema().saveToFile(_fusion_out_index.get_path() + "/schema.txt"); if (!DocumentSummary::writeDocIdLimit(_fusion_out_index.get_path(), _fusion_out_index.get_doc_id_limit())) { LOG(error, "Could not write docsum count in dir %s: %s", _fusion_out_index.get_path().c_str(), getLastErrorString().c_str()); diff --git a/searchlib/src/vespa/searchlib/diskindex/indexbuilder.cpp b/searchlib/src/vespa/searchlib/diskindex/indexbuilder.cpp index 93aff8e7226..3c157bb22d4 100644 --- a/searchlib/src/vespa/searchlib/diskindex/indexbuilder.cpp +++ b/searchlib/src/vespa/searchlib/diskindex/indexbuilder.cpp @@ -10,6 +10,7 @@ #include <vespa/searchlib/diskindex/fieldwriter.h> #include <vespa/vespalib/util/array.hpp> #include <vespa/vespalib/util/error.h> +#include <filesystem> #include <vespa/log/log.h> LOG_SETUP(".diskindex.indexbuilder"); @@ -298,14 +299,14 @@ IndexBuilder::open(uint32_t docIdLimit, uint64_t numWordIds, _docIdLimit = docIdLimit; _numWordIds = numWordIds; if (!_prefix.empty()) { - vespalib::mkdir(_prefix, false); + std::filesystem::create_directory(std::filesystem::path(_prefix)); } // TODO: Filter for text indexes for (FieldHandle & fh : _fields) { if (!fh.getValid()) { continue; } - vespalib::mkdir(fh.getDir(), false); + std::filesystem::create_directory(std::filesystem::path(fh.getDir())); fh.open(docIdLimit, numWordIds, field_length_inspector.get_field_length_info(fh.getName()), tuneFileIndexing._write, diff --git a/searchlib/src/vespa/searchlib/test/directory_handler.h b/searchlib/src/vespa/searchlib/test/directory_handler.h index 3ff753fd3bd..caa3ecd6f5b 100644 --- a/searchlib/src/vespa/searchlib/test/directory_handler.h +++ b/searchlib/src/vespa/searchlib/test/directory_handler.h @@ -2,8 +2,8 @@ #pragma once -#include <vespa/vespalib/io/fileutil.h> #include <vespa/vespalib/stllike/string.h> +#include <filesystem> namespace search::test { @@ -25,11 +25,11 @@ public: _rmdir(rmdir), _cleanup(true) { - vespalib::mkdir(_mkdir); + std::filesystem::create_directories(std::filesystem::path(_mkdir)); } ~DirectoryHandler() { if (_cleanup) { - vespalib::rmdir(_rmdir, true); + std::filesystem::remove_all(std::filesystem::path(_rmdir)); } } void cleanup(bool v) { _cleanup = v; } diff --git a/searchlib/src/vespa/searchlib/transactionlog/translogserver.cpp b/searchlib/src/vespa/searchlib/transactionlog/translogserver.cpp index b5806e1f962..a7aa2384bbc 100644 --- a/searchlib/src/vespa/searchlib/transactionlog/translogserver.cpp +++ b/searchlib/src/vespa/searchlib/transactionlog/translogserver.cpp @@ -11,6 +11,7 @@ #include <vespa/vespalib/util/exceptions.h> #include <vespa/vespalib/util/size_literals.h> #include <vespa/vespalib/util/stringfmt.h> +#include <filesystem> #include <fstream> #include <thread> @@ -345,14 +346,14 @@ writeDomainDir(std::shared_lock<std::shared_mutex> &guard, { (void) guard; vespalib::string domainListTmp(domainList + ".tmp"); - vespalib::unlink(domainListTmp); + std::filesystem::remove(std::filesystem::path(domainListTmp)); std::ofstream domainDir(domainListTmp.c_str(), std::ios::trunc); for (const auto &domainEntry : domains) { domainDir << domainEntry.first << std::endl; } domainDir.close(); vespalib::File::sync(domainListTmp); - vespalib::rename(domainListTmp, domainList, false, false); + std::filesystem::rename(std::filesystem::path(domainListTmp), std::filesystem::path(domainList)); vespalib::File::sync(dir); } @@ -475,7 +476,7 @@ TransLogServer::deleteDomain(FRT_RPCRequest *req) WriteGuard domainGuard(_domainMutex); _domains.erase(domainName); } - vespalib::rmdir(Domain::getDir(dir(), domainName), true); + std::filesystem::remove_all(std::filesystem::path(Domain::getDir(dir(), domainName))); vespalib::File::sync(dir()); ReadGuard domainGuard(_domainMutex); writeDomainDir(domainGuard, dir(), domainList(), _domains); |