-
Notifications
You must be signed in to change notification settings - Fork 15
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Replace Boost.filesystem with std::filesystem
n.b. These changes don't actually remove Boost.filesystem dependency from the CMake build. Re ECFLOW-1922
- Loading branch information
1 parent
07b347e
commit f268433
Showing
126 changed files
with
633 additions
and
807 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
/* | ||
* Copyright 2023- ECMWF. | ||
* | ||
* This software is licensed under the terms of the Apache Licence version 2.0 | ||
* which can be obtained at http://www.apache.org/licenses/LICENSE-2.0. | ||
* In applying this licence, ECMWF does not waive the privileges and immunities | ||
* granted to it by virtue of its status as an intergovernmental organisation | ||
* nor does it submit to any jurisdiction. | ||
*/ | ||
|
||
#include "Filesystem.hpp" | ||
|
||
#include <random> | ||
|
||
namespace ecf { | ||
|
||
namespace details { | ||
struct FilenameGenerator | ||
{ | ||
std::string generate(std::string pattern, char placeholder = '%') { | ||
for (auto& c : pattern) { | ||
if (c == placeholder) { | ||
c = generate_random_hex_digit(); | ||
} | ||
} | ||
return pattern; | ||
} | ||
|
||
private: | ||
char generate_random_hex_digit() { | ||
auto idx = distribution_(rng_); | ||
return hex_[idx]; | ||
} | ||
|
||
static constexpr const char* hex_ = "0123456789abcdef"; | ||
|
||
std::random_device dev_{}; | ||
std::mt19937 rng_{dev_()}; | ||
std::uniform_int_distribution<std::mt19937::result_type> distribution_{0, 15}; | ||
}; | ||
|
||
} // namespace details | ||
|
||
fs::path ecf::unique_path(const fs::path& source) { | ||
details::FilenameGenerator fg; | ||
return fg.generate(source); | ||
} | ||
|
||
} // namespace ecf |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
/* | ||
* Copyright 2023- ECMWF. | ||
* | ||
* This software is licensed under the terms of the Apache Licence version 2.0 | ||
* which can be obtained at http://www.apache.org/licenses/LICENSE-2.0. | ||
* In applying this licence, ECMWF does not waive the privileges and immunities | ||
* granted to it by virtue of its status as an intergovernmental organisation | ||
* nor does it submit to any jurisdiction. | ||
*/ | ||
|
||
#ifndef ECFLOW_CORE_FILESYSTEM_HPP | ||
#define ECFLOW_CORE_FILESYSTEM_HPP | ||
|
||
#include <cassert> | ||
#include <filesystem> | ||
|
||
namespace fs = std::filesystem; | ||
|
||
namespace ecf { | ||
|
||
namespace details { | ||
|
||
template <typename Clock, typename Duration> | ||
inline time_t as_time_t(const std::chrono::time_point<Clock, Duration>& tp) { | ||
return std::chrono::duration_cast<std::chrono::seconds>(tp.time_since_epoch()).count(); | ||
} | ||
|
||
} // namespace details | ||
|
||
inline time_t last_write_time_as_time_t(const fs::path& p) { | ||
return details::as_time_t(fs::last_write_time(fs::path(p))); | ||
} | ||
|
||
fs::path unique_path(const fs::path& source); | ||
|
||
} // namespace ecf | ||
|
||
#endif |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.