Skip to content

Commit 8e6a6c9

Browse files
Remove deprecated Dir functions (#1555)
Use correct one instead Relates-To: OCMAM-212 Signed-off-by: Andrey Kashcheev <ext-andrey.kashcheev@here.com>
1 parent 5a9ded8 commit 8e6a6c9

10 files changed

Lines changed: 27 additions & 67 deletions

File tree

olp-cpp-sdk-core/include/olp/core/utils/Dir.h

Lines changed: 0 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -38,17 +38,6 @@ class CORE_API Dir {
3838
/// An alias for the path callback function.
3939
using PathCallback = std::function<void(const std::string&)>;
4040

41-
/**
42-
* @brief Checks whether a directory exists.
43-
*
44-
* @param path The path of the directory.
45-
*
46-
* @return True if the directory exists; false otherwise.
47-
*
48-
* @deprecated Will be removed by 10/2020. Use `Exists()` instead.
49-
*/
50-
static bool exists(const std::string& path);
51-
5241
/**
5342
* @brief Checks whether a directory exists.
5443
*
@@ -58,17 +47,6 @@ class CORE_API Dir {
5847
*/
5948
static bool Exists(const std::string& path);
6049

61-
/**
62-
* @brief Removes a directory and deletes all its subfolders and files.
63-
*
64-
* @param path The path of the directory.
65-
*
66-
* @return True if the operation is successful; false otherwise.
67-
*
68-
* @deprecated Will be removed by 10/2020. Use `Remove()` instead.
69-
*/
70-
static bool remove(const std::string& path);
71-
7250
/**
7351
* @brief Removes a directory and deletes all its subfolders and files.
7452
*
@@ -78,18 +56,6 @@ class CORE_API Dir {
7856
*/
7957
static bool Remove(const std::string& path);
8058

81-
/**
82-
* @brief Creates a directory and all required directories specified
83-
* in the path.
84-
*
85-
* @param path The path of the directory.
86-
*
87-
* @return True if the operation is successful; false otherwise.
88-
*
89-
* @deprecated Will be removed by 10/2020. Use `Create()` instead.
90-
*/
91-
static bool create(const std::string& path);
92-
9359
/**
9460
* @brief Creates a directory and all required directories specified
9561
* in the path.

olp-cpp-sdk-core/src/cache/DiskCache.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -169,7 +169,7 @@ bool DiskCache::Clear() {
169169
Close();
170170

171171
if (!disk_cache_path_.empty()) {
172-
return olp::utils::Dir::remove(disk_cache_path_);
172+
return olp::utils::Dir::Remove(disk_cache_path_);
173173
}
174174

175175
return true;
@@ -200,8 +200,8 @@ OpenResult DiskCache::Open(const std::string& data_path,
200200
bool repair_if_broken) {
201201
disk_cache_path_ = data_path;
202202
bool is_read_only = (options & ReadOnly) == ReadOnly;
203-
if (!olp::utils::Dir::exists(disk_cache_path_)) {
204-
if (!olp::utils::Dir::create(disk_cache_path_)) {
203+
if (!olp::utils::Dir::Exists(disk_cache_path_)) {
204+
if (!olp::utils::Dir::Create(disk_cache_path_)) {
205205
return OpenResult::Fail;
206206
}
207207
}

olp-cpp-sdk-core/src/utils/Dir.cpp

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -252,8 +252,6 @@ bool Dir::Exists(const std::string& path) {
252252
#endif // _WIN32
253253
}
254254

255-
bool Dir::exists(const std::string& path) { return Dir::Exists(path); }
256-
257255
bool Dir::Remove(const std::string& path) {
258256
bool ret = true;
259257
#if defined(_WIN32) && !defined(__MINGW32__)
@@ -275,10 +273,8 @@ bool Dir::Remove(const std::string& path) {
275273
return ret;
276274
}
277275

278-
bool Dir::remove(const std::string& path) { return Dir::Remove(path); }
279-
280276
bool Dir::Create(const std::string& path, bool extend_permissions) {
281-
if (exists(path)) {
277+
if (Exists(path)) {
282278
return true;
283279
}
284280
bool ret = true;
@@ -314,7 +310,7 @@ bool Dir::Create(const std::string& path, bool extend_permissions) {
314310
}
315311
}
316312
dir_path += token[t];
317-
if (!exists(dir_path)) {
313+
if (!Exists(dir_path)) {
318314
#ifdef _UNICODE
319315
std::wstring wstrPath = ConvertStringToWideString(dir_path);
320316
const TCHAR* n_path = wstrPath.c_str();
@@ -333,8 +329,6 @@ bool Dir::Create(const std::string& path, bool extend_permissions) {
333329
return ret;
334330
}
335331

336-
bool Dir::create(const std::string& path) { return Dir::Create(path); }
337-
338332
std::string Dir::TempDirectory() {
339333
#if defined(_WIN32) && !defined(__MINGW32__)
340334
wchar_t path[MAX_PATH];

tests/functional/olp-cpp-sdk-dataservice-read/VersionedLayerClientProtectTest.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ class VersionedLayerClientProtectTest : public ::testing::Test {
4545
olp::cache::CacheSettings cache_settings;
4646
cache_path_ = olp::utils::Dir::TempDirectory() + "/test";
4747
cache_settings.disk_path_mutable = cache_path_;
48-
olp::utils::Dir::remove(cache_path_);
48+
olp::utils::Dir::Remove(cache_path_);
4949
cache_settings.max_memory_cache_size = 0u;
5050
cache_settings.eviction_policy =
5151
olp::cache::EvictionPolicy::kLeastRecentlyUsed;
@@ -66,7 +66,7 @@ class VersionedLayerClientProtectTest : public ::testing::Test {
6666
auto network = std::move(settings_->network_request_handler);
6767
settings_.reset();
6868
mock_server_client_.reset();
69-
olp::utils::Dir::remove(cache_path_);
69+
olp::utils::Dir::Remove(cache_path_);
7070
}
7171

7272
std::shared_ptr<olp::client::OlpClientSettings> settings_;

tests/integration/olp-cpp-sdk-core/DefaultCacheTest.cpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (C) 2020-2023 HERE Europe B.V.
2+
* Copyright (C) 2020-2024 HERE Europe B.V.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -340,7 +340,7 @@ TEST(DefaultCacheTest, ProtectedLruEviction) {
340340
#ifndef WIN32
341341

342342
TEST(DefaultCacheTest, Permissions) {
343-
// Enable the process to use all permissions
343+
// Enable the process to use all permissions
344344
auto old_mask = umask(0);
345345

346346
{
@@ -368,7 +368,7 @@ TEST(DefaultCacheTest, Permissions) {
368368
EXPECT_TRUE((permissions & S_IXOTH) == 0);
369369
}
370370

371-
EXPECT_TRUE(olp::utils::Dir::remove("./cache"));
371+
EXPECT_TRUE(olp::utils::Dir::Remove("./cache"));
372372

373373
{
374374
SCOPED_TRACE("Modified permission");
@@ -395,7 +395,7 @@ TEST(DefaultCacheTest, Permissions) {
395395
EXPECT_TRUE((permissions & S_IXOTH) == 0);
396396
}
397397

398-
EXPECT_TRUE(olp::utils::Dir::remove("./cache"));
398+
EXPECT_TRUE(olp::utils::Dir::Remove("./cache"));
399399

400400
// Restore the mask
401401
umask(old_mask);

tests/integration/olp-cpp-sdk-dataservice-read/CatalogClientCacheTest.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (C) 2019-2022 HERE Europe B.V.
2+
* Copyright (C) 2019-2024 HERE Europe B.V.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -93,7 +93,7 @@ class CatalogClientCacheTest : public integration::CatalogClientTestBase {
9393
}
9494

9595
protected:
96-
void ClearCache(const std::string& path) { olp::utils::Dir::remove(path); }
96+
void ClearCache(const std::string& path) { olp::utils::Dir::Remove(path); }
9797

9898
std::shared_ptr<olp::cache::DefaultCache> cache_;
9999
};

tests/integration/olp-cpp-sdk-dataservice-read/VersionedLayerClientCacheTest.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (C) 2019-2020 HERE Europe B.V.
2+
* Copyright (C) 2019-2024 HERE Europe B.V.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -97,7 +97,7 @@ class VersionedLayerClientCacheTest
9797
}
9898

9999
protected:
100-
void ClearCache(const std::string& path) { olp::utils::Dir::remove(path); }
100+
void ClearCache(const std::string& path) { olp::utils::Dir::Remove(path); }
101101

102102
std::shared_ptr<olp::cache::DefaultCache> cache_;
103103
};

tests/integration/olp-cpp-sdk-dataservice-read/VersionedLayerClientTest.cpp

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -4224,7 +4224,7 @@ TEST_F(DataserviceReadVersionedLayerClientTest, ProtectAndReleaseTileKeys) {
42244224
olp::cache::CacheSettings cache_settings;
42254225
const std::string cache_path =
42264226
olp::utils::Dir::TempDirectory() + "/integration_test";
4227-
olp::utils::Dir::remove(cache_path);
4227+
olp::utils::Dir::Remove(cache_path);
42284228
cache_settings.disk_path_mutable = cache_path;
42294229
std::shared_ptr<olp::cache::KeyValueCache> cache =
42304230
olp::client::OlpClientSettingsFactory::CreateDefaultCache(cache_settings);
@@ -4265,7 +4265,7 @@ TEST_F(DataserviceReadVersionedLayerClientTest, ProtectAndReleaseTileKeys) {
42654265
ASSERT_TRUE(client.Release({tile_key}));
42664266
ASSERT_FALSE(client.IsCached(tile_key));
42674267
// remove cache
4268-
olp::utils::Dir::remove(cache_path);
4268+
olp::utils::Dir::Remove(cache_path);
42694269
}
42704270

42714271
TEST_F(DataserviceReadVersionedLayerClientTest, ProtectAndReleasePartition) {
@@ -4280,7 +4280,7 @@ TEST_F(DataserviceReadVersionedLayerClientTest, ProtectAndReleasePartition) {
42804280
olp::cache::CacheSettings cache_settings;
42814281
const std::string cache_path =
42824282
olp::utils::Dir::TempDirectory() + "/integration_test";
4283-
olp::utils::Dir::remove(cache_path);
4283+
olp::utils::Dir::Remove(cache_path);
42844284
cache_settings.disk_path_mutable = cache_path;
42854285
std::shared_ptr<olp::cache::KeyValueCache> cache =
42864286
olp::client::OlpClientSettingsFactory::CreateDefaultCache(cache_settings);
@@ -4321,7 +4321,7 @@ TEST_F(DataserviceReadVersionedLayerClientTest, ProtectAndReleaseWithEviction) {
43214321
const std::string blob_data(data_size, 0);
43224322
const std::string cache_path =
43234323
olp::utils::Dir::TempDirectory() + "/integration_test";
4324-
olp::utils::Dir::remove(cache_path);
4324+
olp::utils::Dir::Remove(cache_path);
43254325
olp::cache::CacheSettings cache_settings;
43264326
cache_settings.disk_path_mutable = cache_path;
43274327
cache_settings.max_memory_cache_size = 0u;
@@ -4425,7 +4425,7 @@ TEST_F(DataserviceReadVersionedLayerClientTest, ProtectAndReleaseWithEviction) {
44254425
// after release key is evicted
44264426
ASSERT_FALSE(client.IsCached(protected_key));
44274427
// remove cache folder
4428-
olp::utils::Dir::remove(cache_path);
4428+
olp::utils::Dir::Remove(cache_path);
44294429
}
44304430

44314431
TEST_F(DataserviceReadVersionedLayerClientTest, CatalogEndpointProvider) {
@@ -4504,7 +4504,7 @@ TEST_F(DataserviceReadVersionedLayerClientTest, OverlappingQuads) {
45044504
const std::string blob_data(data_size, 0);
45054505
const std::string cache_path =
45064506
olp::utils::Dir::TempDirectory() + "/integration_test";
4507-
olp::utils::Dir::remove(cache_path);
4507+
olp::utils::Dir::Remove(cache_path);
45084508
olp::cache::CacheSettings cache_settings;
45094509
cache_settings.disk_path_mutable = cache_path;
45104510
settings_.cache =
@@ -4583,7 +4583,7 @@ TEST_F(DataserviceReadVersionedLayerClientTest, OverlappingQuads) {
45834583
}
45844584

45854585
// remove cache folder
4586-
olp::utils::Dir::remove(cache_path);
4586+
olp::utils::Dir::Remove(cache_path);
45874587
}
45884588

45894589
TEST_F(DataserviceReadVersionedLayerClientTest, QuadTreeIndex) {

tests/integration/olp-cpp-sdk-dataservice-read/VersionedLayerTestBase.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (C) 2020 HERE Europe B.V.
2+
* Copyright (C) 2020-2024 HERE Europe B.V.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -45,7 +45,7 @@ VersionedLayerTestBase::VersionedLayerTestBase()
4545
: url_generator_(kCatalog, kLayerName, kEndpoint) {}
4646

4747
void VersionedLayerTestBase::SetUp() {
48-
olp::utils::Dir::remove(kCachePathMutable);
48+
olp::utils::Dir::Remove(kCachePathMutable);
4949

5050
network_mock_ = std::make_shared<NetworkMock>();
5151

@@ -66,7 +66,7 @@ void VersionedLayerTestBase::TearDown() {
6666
testing::Mock::VerifyAndClearExpectations(network_mock_.get());
6767
network_mock_.reset();
6868
settings_.task_scheduler.reset();
69-
olp::utils::Dir::remove(kCachePathMutable);
69+
olp::utils::Dir::Remove(kCachePathMutable);
7070
}
7171

7272
void VersionedLayerTestBase::ExpectQuadTreeRequest(

tests/integration/olp-cpp-sdk-dataservice-read/VolatileLayerClientCacheTest.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (C) 2019-2020 HERE Europe B.V.
2+
* Copyright (C) 2019-2024 HERE Europe B.V.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -98,7 +98,7 @@ class VolatileLayerClientCacheTest : public integration::CatalogClientTestBase {
9898
}
9999

100100
protected:
101-
void ClearCache(const std::string& path) { olp::utils::Dir::remove(path); }
101+
void ClearCache(const std::string& path) { olp::utils::Dir::Remove(path); }
102102

103103
std::shared_ptr<olp::cache::DefaultCache> cache_;
104104
};

0 commit comments

Comments
 (0)