summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorTor Egge <Tor.Egge@online.no>2023-07-17 13:49:10 +0200
committerTor Egge <Tor.Egge@online.no>2023-07-17 13:49:10 +0200
commitad6ad6579df67442563eb08131a74f8e1be71a3b (patch)
tree997ba60d58c9a00f4bf870d11e89b4b782225374
parentdab95e8297ce1ddedcd64b57606ad03bfa36dce7 (diff)
Reduce use of vespalib::unlink.
-rw-r--r--searchcore/src/tests/proton/documentdb/fileconfigmanager/fileconfigmanager_test.cpp4
-rw-r--r--searchcore/src/tests/proton/documentmetastore/documentmetastore_test.cpp10
-rw-r--r--searchcore/src/vespa/searchcore/proton/common/hw_info_sampler.cpp3
-rw-r--r--searchcore/src/vespa/searchcorespi/index/diskindexcleaner.cpp2
-rw-r--r--searchcore/src/vespa/searchcorespi/index/indexwriteutilities.cpp2
-rw-r--r--searchlib/src/tests/attribute/reference_attribute/reference_attribute_test.cpp10
-rw-r--r--searchlib/src/vespa/searchlib/common/indexmetainfo.cpp5
7 files changed, 18 insertions, 18 deletions
diff --git a/searchcore/src/tests/proton/documentdb/fileconfigmanager/fileconfigmanager_test.cpp b/searchcore/src/tests/proton/documentdb/fileconfigmanager/fileconfigmanager_test.cpp
index db2675a7779..1fc5c40a47a 100644
--- a/searchcore/src/tests/proton/documentdb/fileconfigmanager/fileconfigmanager_test.cpp
+++ b/searchcore/src/tests/proton/documentdb/fileconfigmanager/fileconfigmanager_test.cpp
@@ -15,9 +15,9 @@
#include <vespa/searchcore/proton/test/documentdb_config_builder.h>
#include <vespa/searchcore/proton/test/transport_helper.h>
#include <vespa/searchsummary/config/config-juniperrc.h>
-#include <vespa/vespalib/io/fileutil.h>
#include <vespa/config-bucketspaces.h>
#include <vespa/vespalib/testkit/test_kit.h>
+#include <filesystem>
using namespace cloud::config::filedistribution;
@@ -165,7 +165,7 @@ TEST_FF("requireThatConfigCanBeSerializedAndDeserialized", Transport(), Document
TEST_FF("requireThatConfigCanBeLoadedWithoutExtraConfigsDataFile", Transport(), DocumentDBConfig::SP(makeBaseConfigSnapshot(f1.transport())))
{
saveBaseConfigSnapshot(f1.transport(), *f2, 70);
- EXPECT_FALSE(vespalib::unlink("out/config-70/extraconfigs.dat"));
+ EXPECT_FALSE(std::filesystem::remove(std::filesystem::path("out/config-70/extraconfigs.dat")));
DocumentDBConfig::SP esnap(makeEmptyConfigSnapshot());
{
FileConfigManager cm(f1.transport(), "out", myId, "dummy");
diff --git a/searchcore/src/tests/proton/documentmetastore/documentmetastore_test.cpp b/searchcore/src/tests/proton/documentmetastore/documentmetastore_test.cpp
index 6e9d4be97aa..f88e89db25e 100644
--- a/searchcore/src/tests/proton/documentmetastore/documentmetastore_test.cpp
+++ b/searchcore/src/tests/proton/documentmetastore/documentmetastore_test.cpp
@@ -21,11 +21,11 @@
#include <vespa/searchlib/queryeval/simpleresult.h>
#include <vespa/searchlib/queryeval/blueprint.h>
#include <vespa/vespalib/gtest/gtest.h>
-#include <vespa/vespalib/io/fileutil.h>
#include <vespa/vespalib/test/insertion_operators.h>
#include <vespa/vespalib/util/exceptions.h>
#include <vespa/vespalib/util/size_literals.h>
#include <vespa/vespalib/util/threadstackexecutor.h>
+#include <filesystem>
#include <thread>
#include <vespa/log/log.h>
@@ -525,7 +525,7 @@ TEST(DocumentMetaStoreTest, gids_can_be_saved_and_loaded)
EXPECT_EQ(numLids + 1, dms2.getNumDocs());
EXPECT_EQ(numLids - (3 - i), dms2.getNumUsedLids());
}
- vespalib::unlink("documentmetastore2.dat");
+ std::filesystem::remove(std::filesystem::path("documentmetastore2.dat"));
}
TEST(DocumentMetaStoreTest, bucket_used_bits_are_lbounded_at_load_time)
@@ -551,7 +551,7 @@ TEST(DocumentMetaStoreTest, bucket_used_bits_are_lbounded_at_load_time)
BucketId expected_bucket(storage::spi::BucketLimits::MinUsedBits, gid.convertToBucketId().getRawId());
assertGid(gid, lid, dms2, expected_bucket, Timestamp(1000));
- vespalib::unlink("documentmetastore2.dat");
+ std::filesystem::remove(std::filesystem::path("documentmetastore2.dat"));
}
TEST(DocumentMetaStore, stats_are_updated)
@@ -1915,8 +1915,8 @@ TEST(DocumentMetaStoreTest, document_sizes_are_saved)
assertSize(dms4, 1, 1);
assertSize(dms4, 2, 1);
assertSize(dms4, 3, 1);
- vespalib::unlink("documentmetastore3.dat");
- vespalib::unlink("documentmetastore4.dat");
+ std::filesystem::remove(std::filesystem::path("documentmetastore3.dat"));
+ std::filesystem::remove(std::filesystem::path("documentmetastore4.dat"));
}
namespace {
diff --git a/searchcore/src/vespa/searchcore/proton/common/hw_info_sampler.cpp b/searchcore/src/vespa/searchcore/proton/common/hw_info_sampler.cpp
index e25eb5c422c..c893bb6fe2b 100644
--- a/searchcore/src/vespa/searchcore/proton/common/hw_info_sampler.cpp
+++ b/searchcore/src/vespa/searchcore/proton/common/hw_info_sampler.cpp
@@ -5,7 +5,6 @@
#include <vespa/config/print/fileconfigwriter.h>
#include <vespa/config/subscription/configsubscriber.hpp>
#include <vespa/fastos/file.h>
-#include <vespa/vespalib/io/fileutil.h>
#include <vespa/vespalib/util/time.h>
#include <vespa/vespalib/util/resource_limits.h>
#include <vespa/vespalib/util/size_literals.h>
@@ -107,7 +106,7 @@ double measureDiskWriteSpeed(const vespalib::string &path,
double elapsed = vespalib::to_s(after - before);
diskWriteSpeed = diskWriteLen / elapsed / 1_Mi;
}
- vespalib::unlink(fileName);
+ std::filesystem::remove(std::filesystem::path(fileName));
return diskWriteSpeed;
}
diff --git a/searchcore/src/vespa/searchcorespi/index/diskindexcleaner.cpp b/searchcore/src/vespa/searchcorespi/index/diskindexcleaner.cpp
index 704364dfb9b..51d6938b13b 100644
--- a/searchcore/src/vespa/searchcorespi/index/diskindexcleaner.cpp
+++ b/searchcore/src/vespa/searchcorespi/index/diskindexcleaner.cpp
@@ -39,7 +39,7 @@ bool isValidIndex(const string &index_dir) {
}
void invalidateIndex(const string &index_dir) {
- vespalib::unlink(index_dir + "/serial.dat");
+ std::filesystem::remove(std::filesystem::path(index_dir + "/serial.dat"));
vespalib::File::sync(index_dir);
}
diff --git a/searchcore/src/vespa/searchcorespi/index/indexwriteutilities.cpp b/searchcore/src/vespa/searchcorespi/index/indexwriteutilities.cpp
index 97afce79861..8e1940cdc08 100644
--- a/searchcore/src/vespa/searchcorespi/index/indexwriteutilities.cpp
+++ b/searchcore/src/vespa/searchcorespi/index/indexwriteutilities.cpp
@@ -159,7 +159,7 @@ IndexWriteUtilities::updateDiskIndexSchema(const vespalib::string &indexDir,
}
vespalib::string schemaTmpName = schemaName + ".tmp";
vespalib::string schemaOrigName = schemaName + ".orig";
- vespalib::unlink(schemaTmpName);
+ std::filesystem::remove(std::filesystem::path(schemaTmpName));
if (!newSchema->saveToFile(schemaTmpName)) {
LOG(error, "Could not save schema to '%s'",
schemaTmpName.c_str());
diff --git a/searchlib/src/tests/attribute/reference_attribute/reference_attribute_test.cpp b/searchlib/src/tests/attribute/reference_attribute/reference_attribute_test.cpp
index e356187a19f..07b64864d9a 100644
--- a/searchlib/src/tests/attribute/reference_attribute/reference_attribute_test.cpp
+++ b/searchlib/src/tests/attribute/reference_attribute/reference_attribute_test.cpp
@@ -13,9 +13,9 @@
#include <vespa/searchlib/test/mock_gid_to_lid_mapping.h>
#include <vespa/searchcommon/attribute/config.h>
#include <vespa/vespalib/gtest/gtest.h>
-#include <vespa/vespalib/io/fileutil.h>
#include <vespa/vespalib/test/insertion_operators.h>
#include <cinttypes>
+#include <filesystem>
#include <vespa/log/log.h>
LOG_SETUP("reference_attribute_test");
@@ -312,8 +312,8 @@ TEST_F(ReferenceAttributeTest, attribute_can_be_saved_and_loaded)
assertRef(doc1, 1);
assertRef(doc2, 2);
assertRef(doc1, 4);
- EXPECT_TRUE(vespalib::unlink("test.dat"));
- EXPECT_TRUE(vespalib::unlink("test.udat"));
+ EXPECT_TRUE(std::filesystem::remove(std::filesystem::path("test.dat")));
+ EXPECT_TRUE(std::filesystem::remove(std::filesystem::path("test.udat")));
}
TEST_F(ReferenceAttributeTest, update_uses_gid_mapper_to_set_target_lid)
@@ -399,8 +399,8 @@ TEST_F(ReferenceAttributeTest, populateTargetLids_uses_gid_mapper_to_update_lid_
save();
load();
checkPopulateTargetLids(*this);
- EXPECT_TRUE(vespalib::unlink("test.dat"));
- EXPECT_TRUE(vespalib::unlink("test.udat"));
+ EXPECT_TRUE(std::filesystem::remove(std::filesystem::path("test.dat")));
+ EXPECT_TRUE(std::filesystem::remove(std::filesystem::path("test.udat")));
}
TEST_F(ReferenceAttributeTest, populateTargetLids_handles_removes)
diff --git a/searchlib/src/vespa/searchlib/common/indexmetainfo.cpp b/searchlib/src/vespa/searchlib/common/indexmetainfo.cpp
index 60d04d7e3ad..42c9ed4e1c6 100644
--- a/searchlib/src/vespa/searchlib/common/indexmetainfo.cpp
+++ b/searchlib/src/vespa/searchlib/common/indexmetainfo.cpp
@@ -4,8 +4,9 @@
#include <vespa/vespalib/io/fileutil.h>
#include <vespa/vespalib/util/stringfmt.h>
#include <vespa/vespalib/util/guard.h>
-#include <cassert>
#include <algorithm>
+#include <cassert>
+#include <filesystem>
#include <vespa/log/log.h>
LOG_SETUP(".indexmetainfo");
@@ -305,7 +306,7 @@ IndexMetaInfo::save(const vespalib::string &baseName)
{
vespalib::string fileName = makeFileName(baseName);
vespalib::string newName = fileName + ".new";
- vespalib::unlink(newName);
+ std::filesystem::remove(std::filesystem::path(newName));
vespalib::FilePointer f(fopen(newName.c_str(), "w"));
if (!f.valid()) {
LOG(warning, "could not open file for writing: %s", newName.c_str());