Skip to content

Commit 24c4c11

Browse files
Hubert DegaudenziHubert Degaudenzi
authored andcommitted
Merge branch 'feature/StdFileSystem' into develop
2 parents ef32579 + f5698a3 commit 24c4c11

28 files changed

+150
-142
lines changed

ElementsExamples/src/program/AnotherSimpleProgram.cpp

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,6 @@
2121

2222
#include <iostream> // for char_traits, basic_ostream, operator<<, endl, cout
2323

24-
#include <boost/filesystem/path.hpp> // for operator<<
25-
2624
#include "ElementsKernel/Exception.h" // for Exception
2725
#include "ElementsKernel/SimpleProgram.h" // for MAIN, SimpleProgram
2826

ElementsKernel/ElementsKernel/Path.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@
4040
#include <utility> // for forward
4141
#include <vector> // for vector
4242

43-
#include <boost/filesystem/path.hpp> // for path
43+
#include <filesystem>
4444

4545
#include "ElementsKernel/Export.h" // ELEMENTS_API
4646

@@ -58,7 +58,7 @@ enum class Type { executable, library, python, configuration, auxiliary };
5858
* @typedef local alias for the path
5959
* @ingroup ElementsKernel
6060
*/
61-
using Item = boost::filesystem::path;
61+
using Item = std::filesystem::path;
6262

6363
/**
6464
* @brief Separator of path entries. Usually ":" on Unix.

ElementsKernel/ElementsKernel/Temporary.h

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,17 @@ namespace Elements {
3838
const std::string DEFAULT_TMP_KEEP_VAR{"KEEPTEMPDIR"};
3939
/// The default random creation motif
4040
const std::string DEFAULT_TMP_MOTIF{"%%%%-%%%%-%%%%-%%%%"};
41+
/// Defualt max number of attempt to find a random path
42+
const int DEFAULT_TMP_MAX_ATTEMPTS{100};
43+
44+
/**
45+
* @brief Geenrate a unique random path according to to a pattern
46+
* @ingroup ElementsKernel
47+
* @param p
48+
* initial pattern
49+
* @return the path random path stem
50+
*/
51+
ELEMENTS_API Path::Item uniquePath(Path::Item const& p = DEFAULT_TMP_MOTIF);
4152

4253
class ELEMENTS_API TempPath {
4354
public:

ElementsKernel/ElementsKernel/_impl/Path.tpp

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -26,15 +26,14 @@
2626
#else
2727

2828
#include <algorithm> // IWYU pragma: keep
29+
#include <filesystem> // for exists
2930
#include <iosfwd> // for ptrdiff_t
3031
#include <string> // for string
3132
#include <unordered_set> // for unordered_set
3233
#include <utility> // for forward, pair
3334
#include <vector> // for vector
3435

35-
#include <boost/algorithm/string.hpp> // for join
36-
#include <boost/filesystem/operations.hpp> // for exists
37-
#include <boost/filesystem/path.hpp> // for operator/, path
36+
#include <boost/algorithm/string.hpp> // for join
3837

3938
namespace Elements {
4039
inline namespace Kernel {
@@ -68,7 +67,7 @@ std::vector<Item> getAllPathFromLocations(const T& file_name, const std::vector<
6867
});
6968

7069
auto found_pos = std::remove_if(file_list.begin(), file_list.end(), [](const Item& p) {
71-
return not boost::filesystem::exists(p);
70+
return not std::filesystem::exists(p);
7271
});
7372

7473
file_list.erase(found_pos, file_list.end());

ElementsKernel/ElementsKernel/_impl/PathSearch.tpp

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -26,10 +26,9 @@
2626
#error "This file should not be included directly! Use ElementsKernel/PathSearch.h instead"
2727
#else
2828

29-
#include <string> // for string
30-
#include <vector> // for vector
31-
32-
#include <boost/filesystem.hpp> // for is_directory
29+
#include <filesystem> // for directory_iterator, recursive_directory_iterator>
30+
#include <string> // for string
31+
#include <vector> // for vector
3332

3433
#include "ElementsKernel/Path.h" // for Item
3534

@@ -46,7 +45,7 @@ std::vector<T> pathSearch(const std::string& searched_name, T directory) {
4645
Path::Item l_directory{directory};
4746
// the default constructor of ITER return a pointer to one-past last element
4847
ITER end_iter;
49-
if (boost::filesystem::is_directory(l_directory)) {
48+
if (std::filesystem::is_directory(l_directory)) {
5049
// ITER constructor return a pointer to the first element of l_directory
5150
for (ITER dir_iter(l_directory); dir_iter != end_iter; ++dir_iter) {
5251
if (dir_iter->path().filename() == searched_name) {
@@ -67,10 +66,10 @@ std::vector<T> searchOption(std::string searched_name, T directory, SearchType s
6766
std::vector<T> searchResults{};
6867
switch (search_type) {
6968
case SearchType::Local:
70-
searchResults = pathSearch<T, boost::filesystem::directory_iterator>(searched_name, directory);
69+
searchResults = pathSearch<T, std::filesystem::directory_iterator>(searched_name, directory);
7170
break;
7271
case SearchType::Recursive:
73-
searchResults = pathSearch<T, boost::filesystem::recursive_directory_iterator>(searched_name, directory);
72+
searchResults = pathSearch<T, std::filesystem::recursive_directory_iterator>(searched_name, directory);
7473
break;
7574
}
7675
return searchResults;

ElementsKernel/ElementsKernel/_impl/ProgramManager.tpp

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -27,9 +27,6 @@
2727

2828
#include <iostream> // for operator<<, basic_ostream, char_traits, endl, cerr
2929

30-
#include <boost/filesystem/operations.hpp> // for exists
31-
#include <boost/filesystem/path.hpp> // for operator<<
32-
3330
#include "ElementsKernel/Exit.h" // for ExitCode
3431
#include "ElementsKernel/Path.h" // for Item
3532

ElementsKernel/src/Lib/Auxiliary.cpp

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -26,9 +26,6 @@
2626
#include <string> // for string
2727
#include <vector> // for vector
2828

29-
#include <boost/filesystem/operations.hpp> // for exists
30-
#include <boost/filesystem/path.hpp> // for operator/, path
31-
3229
#include "ElementsKernel/Path.h" // for Type, Item, VARIABLE
3330
#include "ElementsKernel/System.h" // for DEFAULT_INSTALL_PREFIX
3431

ElementsKernel/src/Lib/Configuration.cpp

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -26,9 +26,6 @@
2626
#include <string> // for string
2727
#include <vector> // for vector
2828

29-
#include <boost/filesystem/operations.hpp> // for exists
30-
#include <boost/filesystem/path.hpp> // for operator/, path
31-
3229
#include "ElementsKernel/Path.h" // for Path::VARIABLE, Path::Type
3330
#include "ElementsKernel/System.h" // for DEFAULT_INSTALL_PREFIX
3431

ElementsKernel/src/Lib/ModuleInfo.cpp

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -26,17 +26,15 @@
2626
#include <libgen.h> // for __xpg_basename, basename
2727
#include <unistd.h> // for getpid
2828

29-
#include <array> // for array
30-
#include <cstdint> // for int64_t
31-
#include <fstream> // IWYU pragma: keep
29+
#include <array> // for array
30+
#include <cstdint> // for int64_t
31+
#include <filesystem> // for canonical, exists, path
32+
#include <fstream> // IWYU pragma: keep
3233
#include <memory>
3334
#include <sstream> // for basic_istream, basic_ostream, basic_ostream::operator<<, operator<<, basic_ios, ifstream, istringstream, stringstream
3435
#include <string> // for char_traits, basic_string, string, operator>>, getline, operator==
3536
#include <vector> // for vector
3637

37-
#include <boost/filesystem/operations.hpp> // for exists, canonical
38-
#include <boost/filesystem/path.hpp> // for operator/, path
39-
4038
#include "ElementsKernel/FuncPtrCast.h" // for FuncPtrCast
4139
#include "ElementsKernel/Path.h" // for Item
4240

@@ -209,7 +207,7 @@ vector<Path::Item> linkedModulePaths() {
209207
if (not(iss >> address >> perms >> offset >> dev >> inode >> pathname)) {
210208
continue;
211209
}
212-
if (perms == "r-xp" and boost::filesystem::exists(pathname)) {
210+
if (perms == "r-xp" and std::filesystem::exists(pathname)) {
213211
linked_modules.emplace_back(pathname);
214212
}
215213
}

ElementsKernel/src/Lib/PathSearch.cpp

Lines changed: 7 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -21,29 +21,21 @@
2121

2222
#include "ElementsKernel/PathSearch.h"
2323

24-
#include <string> // for allocator, string, basic_string
25-
#include <vector> // for vector
24+
#include <filesystem> // for directory_iterator, recursive_directory_iterator
25+
#include <string> // for allocator, string, basic_string
26+
#include <vector> // for vector
2627

27-
#include <boost/algorithm/string.hpp> // for is_any_ofF, is_any_of, split
28-
#include <boost/filesystem/operations.hpp> // for exists, is_directory
29-
#include <boost/filesystem/path.hpp> // for operator==, path
28+
#include <boost/algorithm/string.hpp> // for is_any_ofF, is_any_of, split
3029

3130
#include "ElementsKernel/Environment.h" // for Environment
3231
#include "ElementsKernel/Logging.h" // for Logging
3332
#include "ElementsKernel/Path.h" // for Item
3433

35-
namespace boost::filesystem {
36-
class directory_iterator;
37-
}
38-
namespace boost::filesystem {
39-
class recursive_directory_iterator;
40-
}
41-
4234
using std::string;
4335
using std::vector;
4436

45-
using boost::filesystem::directory_iterator;
46-
using boost::filesystem::recursive_directory_iterator;
37+
using std::filesystem::directory_iterator;
38+
using std::filesystem::recursive_directory_iterator;
4739

4840
namespace Elements {
4941
inline namespace Kernel {
@@ -93,7 +85,7 @@ vector<Path::Item> pathSearchInEnvVariable(const string& file_name, const string
9385
// Loop over all path elements
9486
for (const string& path_element : path_elements) {
9587
// Check if directory exists
96-
if (boost::filesystem::exists(path_element) && boost::filesystem::is_directory(path_element)) {
88+
if (std::filesystem::exists(path_element) && std::filesystem::is_directory(path_element)) {
9789
// loop recursively inside directory
9890
auto single_path_results = pathSearch(file_name, Path::Item{path_element}, search_type);
9991
search_results.insert(search_results.end(), single_path_results.cbegin(), single_path_results.cend());

0 commit comments

Comments
 (0)