Skip to content

Commit 375249d

Browse files
Removing some instances of Poco::File from Kernel
1 parent 2fa1189 commit 375249d

File tree

8 files changed

+33
-38
lines changed

8 files changed

+33
-38
lines changed

Framework/Kernel/src/FileDescriptor.cpp

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,7 @@
77
#include "MantidKernel/FileDescriptor.h"
88
#include "MantidKernel/Strings.h"
99

10-
#include <Poco/Path.h>
1110
#include <filesystem>
12-
1311
#include <stdexcept>
1412

1513
namespace Mantid::Kernel {
@@ -177,7 +175,7 @@ bool FileDescriptor::isXML() const { return (this->isAscii() && this->extension(
177175
*/
178176
void FileDescriptor::initialize(const std::string &filename) {
179177
m_filename = filename;
180-
m_extension = Mantid::Kernel::Strings::toLower("." + Poco::Path(filename).getExtension());
178+
m_extension = Mantid::Kernel::Strings::toLower(std::filesystem::path(filename).extension().string());
181179

182180
m_file.open(m_filename.c_str(), std::ios::in | std::ios::binary);
183181
if (!m_file)

Framework/Kernel/src/FileValidator.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -75,9 +75,9 @@ std::string FileValidator::checkValidity(const std::string &value) const {
7575
// create a variable for the absolute path to be used in error messages
7676
std::string abspath(value);
7777
if (!value.empty()) {
78-
Poco::Path path(value);
79-
if (path.isAbsolute())
80-
abspath = path.toString();
78+
std::filesystem::path path(value);
79+
if (path.is_absolute())
80+
abspath = std::filesystem::absolute(path).string();
8181
}
8282

8383
// If the file is required to exist check it is there

Framework/Kernel/src/NexusDescriptor.cpp

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -11,11 +11,9 @@
1111
#include <nexus/NeXusException.hpp>
1212
// clang-format on
1313

14-
#include <filesystem>
15-
#include <Poco/Path.h>
16-
1714
#include <algorithm>
1815
#include <cstring>
16+
#include <filesystem>
1917
#include <string>
2018

2119
namespace Mantid::Kernel {
@@ -211,7 +209,7 @@ bool NexusDescriptor::classTypeExists(const std::string &classType) const {
211209
*/
212210
void NexusDescriptor::initialize(const std::string &filename) {
213211
m_filename = filename;
214-
m_extension = "." + Poco::Path(filename).getExtension();
212+
m_extension = std::filesystem::path(filename).extension().string();
215213

216214
m_file = std::make_unique<::NeXus::File>(this->filename());
217215

Framework/Kernel/test/AttenuationProfileTest.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,9 @@ class AttenuationProfileTest : public CxxTest::TestSuite {
2525

2626
void testLoadAttenuationFile() {
2727
std::string path = Mantid::Kernel::ConfigService::Instance().getFullPath("AttenuationProfile.DAT", false, 0);
28+
TS_ASSERT(!path.empty());
29+
std::cout << "***" << path << "***\n";
30+
auto profile = AttenuationProfile(path, "");
2831
TS_ASSERT_THROWS_NOTHING(auto profile = AttenuationProfile(path, ""));
2932
}
3033

Framework/Kernel/test/DirectoryValidatorTest.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@
99
#include <cxxtest/TestSuite.h>
1010

1111
#include "MantidKernel/DirectoryValidator.h"
12-
#include <Poco/File.h>
1312
#include <filesystem>
1413
#include <fstream>
1514

Framework/Kernel/test/FileDescriptorTest.h

Lines changed: 12 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@
1212
#include "MantidKernel/ConfigService.h"
1313
#include "MantidKernel/FileDescriptor.h"
1414

15-
#include <Poco/Path.h>
1615
#include <filesystem>
1716

1817
using Mantid::Kernel::FileDescriptor;
@@ -29,18 +28,18 @@ class FileDescriptorTest : public CxxTest::TestSuite {
2928
cfg.reset();
3029
const auto &dataPaths = cfg.getDataSearchDirs();
3130
for (const auto &dataPath : dataPaths) {
32-
Poco::Path nxsPath(dataPath, "CNCS_7860_event.nxs");
33-
if (std::filesystem::exists(nxsPath.toString()))
34-
m_testNexusPath = nxsPath.toString();
35-
Poco::Path nonNxsPath(dataPath, "CSP79590.raw");
36-
if (std::filesystem::exists(nonNxsPath.toString()))
37-
m_testNonNexusPath = nonNxsPath.toString();
38-
Poco::Path asciiPath(dataPath, "AsciiExample.txt");
39-
if (std::filesystem::exists(asciiPath.toString()))
40-
m_testAsciiPath = asciiPath.toString();
41-
Poco::Path emptyFilePath(dataPath, "emptyFile.txt");
42-
if (std::filesystem::exists(emptyFilePath.toString()))
43-
m_emptyFilePath = emptyFilePath.toString();
31+
const auto nxsPath = std::filesystem::path(dataPath) / "CNCS_7860_event.nxs";
32+
if (std::filesystem::exists(nxsPath))
33+
m_testNexusPath = nxsPath.string();
34+
const auto nonNxsPath = std::filesystem::path(dataPath) / "CSP79590.raw";
35+
if (std::filesystem::exists(nonNxsPath))
36+
m_testNonNexusPath = nonNxsPath.string();
37+
const auto asciiPath = std::filesystem::path(dataPath) / "AsciiExample.txt";
38+
if (std::filesystem::exists(asciiPath))
39+
m_testAsciiPath = asciiPath.string();
40+
const auto emptyFilePath = std::filesystem::path(dataPath) / "emptyFile.txt";
41+
if (std::filesystem::exists(emptyFilePath))
42+
m_emptyFilePath = emptyFilePath.string();
4443

4544
if (!m_testNexusPath.empty() && !m_testNonNexusPath.empty() && !m_testAsciiPath.empty() &&
4645
!m_emptyFilePath.empty())

Framework/Kernel/test/NexusDescriptorTest.h

Lines changed: 9 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,6 @@
1313
#include <filesystem>
1414
#include <memory>
1515

16-
#include <Poco/Path.h>
1716
#include <nexus/NeXusFile.hpp>
1817

1918
#include <cstdio>
@@ -31,17 +30,17 @@ class NexusDescriptorTest : public CxxTest::TestSuite {
3130
using Mantid::Kernel::ConfigService;
3231
auto dataPaths = ConfigService::Instance().getDataSearchDirs();
3332
for (auto &dataPath : dataPaths) {
34-
Poco::Path hdf5Path(dataPath, "CNCS_7860_event.nxs");
35-
if (std::filesystem::exists(hdf5Path.toString()))
36-
m_testHDF5Path = hdf5Path.toString();
33+
const auto hdf5Path = std::filesystem::path(dataPath) / "CNCS_7860_event.nxs";
34+
if (std::filesystem::exists(hdf5Path))
35+
m_testHDF5Path = hdf5Path.string();
3736

38-
Poco::Path hdf4Path(dataPath, "argus0026287.nxs");
39-
if (std::filesystem::exists(hdf4Path.toString()))
40-
m_testHDF4Path = hdf4Path.toString();
37+
const auto hdf4Path = std::filesystem::path(dataPath) / "argus0026287.nxs";
38+
if (std::filesystem::exists(hdf4Path))
39+
m_testHDF4Path = hdf4Path.string();
4140

42-
Poco::Path nonhdf5Path(dataPath, "CSP79590.raw");
43-
if (std::filesystem::exists(nonhdf5Path.toString()))
44-
m_testNonHDFPath = nonhdf5Path.toString();
41+
const auto nonhdf5Path = std::filesystem::path(dataPath) / "CSP79590.raw";
42+
if (std::filesystem::exists(nonhdf5Path))
43+
m_testNonHDFPath = nonhdf5Path.string();
4544

4645
if (!m_testHDF5Path.empty() && !m_testHDF4Path.empty() && !m_testNonHDFPath.empty())
4746
break;

Framework/Kernel/test/NexusHDF5DescriptorTest.h

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@
99
#include "MantidKernel/ConfigService.h"
1010
#include "MantidKernel/NexusHDF5Descriptor.h"
1111

12-
#include "Poco/Path.h"
1312
#include <filesystem>
1413

1514
#include <cstddef> // std::size_t
@@ -21,9 +20,9 @@ std::string getFullPath(const std::string &filename) {
2120
using Mantid::Kernel::ConfigService;
2221
auto dataPaths = ConfigService::Instance().getDataSearchDirs();
2322
for (auto &dataPath : dataPaths) {
24-
Poco::Path hdf5Path(dataPath, filename);
25-
if (std::filesystem::exists(hdf5Path.toString())) {
26-
return hdf5Path.toString();
23+
const auto hdf5Path = std::filesystem::path(dataPath) / filename;
24+
if (std::filesystem::exists(hdf5Path)) {
25+
return hdf5Path.string();
2726
}
2827
}
2928
return std::string();

0 commit comments

Comments
 (0)