summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/other_tools/utils/parse_archive.cpp10
-rw-r--r--src/utils/cpp/path.hpp12
2 files changed, 12 insertions, 10 deletions
diff --git a/src/other_tools/utils/parse_archive.cpp b/src/other_tools/utils/parse_archive.cpp
index 848eaace..0f94d26e 100644
--- a/src/other_tools/utils/parse_archive.cpp
+++ b/src/other_tools/utils/parse_archive.cpp
@@ -103,16 +103,6 @@ auto ParseArchiveContent(ExpressionPtr const& repo_desc,
.origin = origin};
}
-auto IsValidFileName(const std::string& s) -> bool {
- if (s.find_first_of("/\0") != std::string::npos) {
- return false;
- }
- if (s.empty() or s == "." or s == "..") {
- return false;
- }
- return true;
-}
-
auto ParseArchiveDescription(ExpressionPtr const& repo_desc,
std::string const& repo_type,
std::string const& origin,
diff --git a/src/utils/cpp/path.hpp b/src/utils/cpp/path.hpp
index 26d25e50..ba3d125b 100644
--- a/src/utils/cpp/path.hpp
+++ b/src/utils/cpp/path.hpp
@@ -16,6 +16,7 @@
#define INCLUDED_SRC_UTILS_CPP_PATH_HPP
#include <filesystem>
+#include <string>
[[nodiscard]] static inline auto ToNormalPath(
std::filesystem::path const& p) noexcept -> std::filesystem::path {
@@ -58,4 +59,15 @@
return PathIsNonUpwards(applied_to.parent_path() / path);
}
+/// \brief Predicate if a given string is a valid filename.
+[[nodiscard]] static inline auto IsValidFileName(const std::string& s) -> bool {
+ if (s.find_first_of("/\0") != std::string::npos) {
+ return false;
+ }
+ if (s.empty() or s == "." or s == "..") {
+ return false;
+ }
+ return true;
+}
+
#endif // INCLUDED_SRC_UTILS_CPP_PATH_HPP