From 495ce415de8a147ab7d4c02f6b60cc65998ab5e0 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Martin=20W=C3=B6lzer?= <martin@libclapp.org>
Date: Sun, 15 Sep 2024 23:01:30 +0200
Subject: [PATCH] src/include/clapp/filesystem.h: removed file

---
 src/clapp/value.cpp              |  6 +++---
 src/include/clapp/CMakeLists.txt |  1 -
 src/include/clapp/argument.h     |  5 +++--
 src/include/clapp/filesystem.h   | 24 -----------------------
 src/include/clapp/option.h       |  7 ++++---
 src/include/clapp/value.h        |  6 +++---
 src/include/clapp/value.hpp      |  2 +-
 tests/argument.cpp               | 33 ++++++++++++++++----------------
 tests/option.cpp                 | 10 +++++-----
 tests/value.cpp                  |  9 +++++----
 usage/main.cpp                   |  1 -
 11 files changed, 41 insertions(+), 63 deletions(-)
 delete mode 100644 src/include/clapp/filesystem.h

diff --git a/src/clapp/value.cpp b/src/clapp/value.cpp
index b97fe64d..e8deedd0 100644
--- a/src/clapp/value.cpp
+++ b/src/clapp/value.cpp
@@ -175,14 +175,14 @@ double clapp::value::convert_value<double>(const std::string_view param) {
 }
 
 template <>
-clapp::fs::path clapp::value::convert_value<clapp::fs::path>(
+std::filesystem::path clapp::value::convert_value<std::filesystem::path>(
     const std::string_view param) {
     return {param};
 }
 
-void clapp::value::path_exists_t::validate(const clapp::fs::path& path,
+void clapp::value::path_exists_t::validate(const std::filesystem::path& path,
                                            const std::string& param_name) {
-    if (!clapp::fs::exists(path)) {
+    if (!std::filesystem::exists(path)) {
         std::stringstream string_stream;
         string_stream << "CLI value '" << path << "' for '" << param_name
                       << "' does not exist.";
diff --git a/src/include/clapp/CMakeLists.txt b/src/include/clapp/CMakeLists.txt
index 18e27c99..387f5243 100644
--- a/src/include/clapp/CMakeLists.txt
+++ b/src/include/clapp/CMakeLists.txt
@@ -5,7 +5,6 @@ install(FILES  "${CMAKE_CURRENT_SOURCE_DIR}/argument.h"
                "${CMAKE_CURRENT_SOURCE_DIR}/contract.h"
                "${CMAKE_CURRENT_SOURCE_DIR}/contract.hpp"
                "${CMAKE_CURRENT_SOURCE_DIR}/exception.h"
-               "${CMAKE_CURRENT_SOURCE_DIR}/filesystem.h"
                "${CMAKE_CURRENT_SOURCE_DIR}/main_parser.h"
                "${CMAKE_CURRENT_SOURCE_DIR}/option.h"
                "${CMAKE_CURRENT_SOURCE_DIR}/option.hpp"
diff --git a/src/include/clapp/argument.h b/src/include/clapp/argument.h
index f0faba96..c5228ab1 100644
--- a/src/include/clapp/argument.h
+++ b/src/include/clapp/argument.h
@@ -166,7 +166,7 @@ class basic_variadic_argument_t {
 
 using bool_argument_t = basic_argument_t<bool>;
 using string_argument_t = basic_argument_t<std::string>;
-using path_argument_t = basic_argument_t<clapp::fs::path>;
+using path_argument_t = basic_argument_t<std::filesystem::path>;
 using int8_argument_t = basic_argument_t<std::int8_t>;
 using uint8_argument_t = basic_argument_t<std::uint8_t>;
 using int16_argument_t = basic_argument_t<std::int16_t>;
@@ -188,7 +188,8 @@ using hours_argument_t = basic_argument_t<std::chrono::hours>;
 
 using variadic_bool_argument_t = basic_variadic_argument_t<bool>;
 using variadic_string_argument_t = basic_variadic_argument_t<std::string>;
-using variadic_path_argument_t = basic_variadic_argument_t<clapp::fs::path>;
+using variadic_path_argument_t =
+    basic_variadic_argument_t<std::filesystem::path>;
 using variadic_int8_argument_t = basic_variadic_argument_t<std::int8_t>;
 using variadic_uint8_argument_t = basic_variadic_argument_t<std::uint8_t>;
 using variadic_int16_argument_t = basic_variadic_argument_t<std::int16_t>;
diff --git a/src/include/clapp/filesystem.h b/src/include/clapp/filesystem.h
deleted file mode 100644
index 1415ae24..00000000
--- a/src/include/clapp/filesystem.h
+++ /dev/null
@@ -1,24 +0,0 @@
-///////////////////////////////////////////////////////////////////////////////
-//
-// Copyright (c) 2020 Martin Wölzer
-//
-// This code is licensed under the MIT License (MIT).
-//
-// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
-// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
-// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
-// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
-// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
-// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
-// SOFTWARE.
-///////////////////////////////////////////////////////////////////////////////
-
-#ifndef CLAPP_FILESYSTEM_H
-#define CLAPP_FILESYSTEM_H
-
-#include <filesystem>
-namespace clapp {
-namespace fs = std::filesystem;
-}  // namespace clapp
-
-#endif
diff --git a/src/include/clapp/option.h b/src/include/clapp/option.h
index 849fea33..9cef5932 100644
--- a/src/include/clapp/option.h
+++ b/src/include/clapp/option.h
@@ -16,10 +16,10 @@
 #ifndef CLAPP_OPTION_H
 #define CLAPP_OPTION_H
 
-#include <clapp/filesystem.h>
 #include <clapp/parser.h>
 #include <clapp/value.h>
 
+#include <filesystem>
 #include <functional>
 #include <optional>
 #include <string>
@@ -302,7 +302,7 @@ using help_option_t = basic_help_option_t<EXIT_SUCCESS>;
 
 using string_param_option_t = basic_param_option_t<std::string>;
 
-using path_param_option_t = basic_param_option_t<clapp::fs::path>;
+using path_param_option_t = basic_param_option_t<std::filesystem::path>;
 
 using bool_param_option_t = basic_param_option_t<bool>;
 using int8_param_option_t = basic_param_option_t<std::int8_t>;
@@ -326,7 +326,8 @@ using hours_param_option_t = basic_param_option_t<std::chrono::hours>;
 
 using vector_string_param_option_t = basic_vector_param_option_t<std::string>;
 
-using vector_path_param_option_t = basic_vector_param_option_t<clapp::fs::path>;
+using vector_path_param_option_t =
+    basic_vector_param_option_t<std::filesystem::path>;
 
 using vector_int8_param_option_t = basic_vector_param_option_t<std::int8_t>;
 using vector_uint8_param_option_t = basic_vector_param_option_t<std::uint8_t>;
diff --git a/src/include/clapp/value.h b/src/include/clapp/value.h
index 35dd35d4..c3d90798 100644
--- a/src/include/clapp/value.h
+++ b/src/include/clapp/value.h
@@ -16,8 +16,7 @@
 #ifndef CLAPP_VALUE_H
 #define CLAPP_VALUE_H
 
-#include <clapp/filesystem.h>
-
+#include <filesystem>
 #include <functional>
 #include <numeric>
 #include <optional>
@@ -101,7 +100,8 @@ class path_exists_t {
     [[nodiscard]] static constexpr std::string_view
     append_restriction_text() noexcept;
 
-    static void validate(const fs::path &path, const std::string &param_name);
+    static void validate(const std::filesystem::path &path,
+                         const std::string &param_name);
 };
 
 inline std::string concat_str(const std::string &lhs, const std::string &rhs);
diff --git a/src/include/clapp/value.hpp b/src/include/clapp/value.hpp
index cad39aad..e07f52e4 100644
--- a/src/include/clapp/value.hpp
+++ b/src/include/clapp/value.hpp
@@ -198,7 +198,7 @@ template <>
 double clapp::value::convert_value<double>(std::string_view param);
 
 template <>
-clapp::fs::path clapp::value::convert_value<clapp::fs::path>(
+std::filesystem::path clapp::value::convert_value<std::filesystem::path>(
     std::string_view param);
 
 std::string clapp::value::concat_str(const std::string& lhs,
diff --git a/tests/argument.cpp b/tests/argument.cpp
index c5f8bd14..aaa3bd44 100644
--- a/tests/argument.cpp
+++ b/tests/argument.cpp
@@ -194,10 +194,10 @@ class argumentT : public ::testing::Test {
     inline static constexpr std::uint16_t value_uint16{0xc234};
     inline static constexpr std::uint8_t value_uint8{0xc2};
     inline static constexpr std::uint8_t value_uint8_additional{0xff};
-    inline static const clapp::fs::path value_path{"/this/is/my/path"};
+    inline static const std::filesystem::path value_path{"/this/is/my/path"};
     inline static constexpr const char* value_path_cstring{
         "/this/is/my/cstring/path"};
-    inline static const clapp::fs::path value_path_additional{
+    inline static const std::filesystem::path value_path_additional{
         "/this/is/my/additional/path"};
     inline static constexpr bool value_true{true};
     inline static constexpr bool value_false{false};
@@ -4379,15 +4379,16 @@ TEST_F(argumentT, pathArgumentConstructStrAndCallArgFunc) {
     clapp::argument::path_argument_t arg{tp, arg_str, desc_str};
     ASSERT_NO_THROW((get_arg_func<argument_test_parser_t::argument_func_t>(
         tp, arg_str)(value_path_cstring)));
-    ASSERT_THAT(arg, ArgumentGiven(clapp::fs::path{value_path_cstring}));
+    ASSERT_THAT(arg, ArgumentGiven(std::filesystem::path{value_path_cstring}));
 }
 
 TEST_F(argumentT, pathArgumentConstructStrWithDefaultValueAndCallArgFunc) {
     clapp::argument::path_argument_t arg{
         tp, arg_str, desc_str, argument_test_parser_t::purpose_t::optional,
-        clapp::value::default_value_t<clapp::fs::path>{value_path_additional}};
+        clapp::value::default_value_t<std::filesystem::path>{
+            value_path_additional}};
     ASSERT_THAT(arg, ArgumentNotGivenDefaultValue(
-                         clapp::fs::path{value_path_additional}));
+                         std::filesystem::path{value_path_additional}));
     ASSERT_NO_THROW((get_arg_func<argument_test_parser_t::argument_func_t>(
         tp, arg_str)(value_path.string())));
     ASSERT_THAT(arg, ArgumentGiven(value_path));
@@ -4429,7 +4430,7 @@ TEST_F(argumentT,
     clapp::argument::variadic_path_argument_t arg{tp, arg_str, desc_str};
     ASSERT_THAT(tp, ContainsArgument(arg_str));
     ASSERT_THAT(arg, ArgumentNotGiven());
-    ASSERT_THAT(arg.value(), testing::Eq(std::vector<clapp::fs::path>{}));
+    ASSERT_THAT(arg.value(), testing::Eq(std::vector<std::filesystem::path>{}));
 }
 
 TEST_F(argumentT, variadicPathArgumentConstructWithAlreadyRegisteredArgThrows) {
@@ -4449,12 +4450,12 @@ TEST_F(argumentT,
         tp, arg_str, desc_str, argument_test_parser_t::purpose_t::optional};
     ASSERT_NO_THROW((get_arg_func<argument_test_parser_t::argument_func_t>(
         tp, arg_str)(value_path.string())));
-    ASSERT_THAT(
-        arg, VariadicArgumentGiven(std::vector<clapp::fs::path>{value_path}));
-    ASSERT_NO_THROW((get_arg_func<argument_test_parser_t::argument_func_t>(
-        tp, arg_str)(clapp::fs::path{value_path}.string())));
     ASSERT_THAT(arg, VariadicArgumentGiven(
-                         std::vector<clapp::fs::path>{value_path, value_path}));
+                         std::vector<std::filesystem::path>{value_path}));
+    ASSERT_NO_THROW((get_arg_func<argument_test_parser_t::argument_func_t>(
+        tp, arg_str)(std::filesystem::path{value_path}.string())));
+    ASSERT_THAT(arg, VariadicArgumentGiven(std::vector<std::filesystem::path>{
+                         value_path, value_path}));
 }
 
 TEST_F(argumentT, variadicPathArgumentConstructStrWithoutCallArgFunc) {
@@ -4465,13 +4466,13 @@ TEST_F(argumentT, variadicPathArgumentConstructStrWithoutCallArgFunc) {
 TEST_F(argumentT, variadicPathArgumentConstructStrAndCallArgFuncMultipleTimes) {
     clapp::argument::variadic_path_argument_t arg{tp, arg_cstr, desc_str};
     ASSERT_NO_THROW((get_arg_func<argument_test_parser_t::argument_func_t>(
-        tp, arg_cstr)(clapp::fs::path{value_path}.string())));
-    ASSERT_THAT(
-        arg, VariadicArgumentGiven(std::vector<clapp::fs::path>{value_path}));
+        tp, arg_cstr)(std::filesystem::path{value_path}.string())));
+    ASSERT_THAT(arg, VariadicArgumentGiven(
+                         std::vector<std::filesystem::path>{value_path}));
     ASSERT_NO_THROW((get_arg_func<argument_test_parser_t::argument_func_t>(
         tp, arg_cstr)(value_path.string())));
-    ASSERT_THAT(arg, VariadicArgumentGiven(
-                         std::vector<clapp::fs::path>{value_path, value_path}));
+    ASSERT_THAT(arg, VariadicArgumentGiven(std::vector<std::filesystem::path>{
+                         value_path, value_path}));
 }
 
 TEST_F(argumentT, variadicPathArgumentConstructCStrWithoutCallArgFunc) {
diff --git a/tests/option.cpp b/tests/option.cpp
index b8b6993f..ec2e51f1 100644
--- a/tests/option.cpp
+++ b/tests/option.cpp
@@ -2179,11 +2179,11 @@ TEST_F(
 
 TEST_F(optionT,
        vectorPathParamOptionConstructLongStringAndShortWithDefaultValueThrows) {
-    ASSERT_THROW(
-        (clapp::option::vector_path_param_option_t{
-            tp, long_opt_str, short_opt, opt_desc_str,
-            clapp::value::default_value_t<clapp::fs::path>{value_cstr_path}}),
-        clapp::option_param_exception_t);
+    ASSERT_THROW((clapp::option::vector_path_param_option_t{
+                     tp, long_opt_str, short_opt, opt_desc_str,
+                     clapp::value::default_value_t<std::filesystem::path>{
+                         value_cstr_path}}),
+                 clapp::option_param_exception_t);
 }
 
 TEST_F(optionT, vectorPathParamOptionConstructShort) {
diff --git a/tests/value.cpp b/tests/value.cpp
index 18bd9f7e..408545ee 100644
--- a/tests/value.cpp
+++ b/tests/value.cpp
@@ -10,8 +10,8 @@ TEST(value, convertValueString) {
 }
 
 TEST(value, convertValuePath) {
-    ASSERT_THAT(clapp::value::convert_value<clapp::fs::path>("/tmp/test"),
-                testing::Eq(clapp::fs::path{"/tmp/test"}));
+    ASSERT_THAT(clapp::value::convert_value<std::filesystem::path>("/tmp/test"),
+                testing::Eq(std::filesystem::path{"/tmp/test"}));
 }
 
 TEST(value, convertValueBool) {
@@ -459,9 +459,10 @@ TEST(value, pathExistsT) {
     clapp::value::path_exists_t path_exists;
     ASSERT_THAT(path_exists.append_restriction_text(),
                 testing::StrEq("existing path"));
-    EXPECT_NO_THROW(path_exists.validate(clapp::fs::path{"/tmp"}, "option"));
+    EXPECT_NO_THROW(
+        path_exists.validate(std::filesystem::path{"/tmp"}, "option"));
     ASSERT_THROW(path_exists.validate(
-                     clapp::fs::path{"/tmp/aba/sadf/aksk/annsp"}, "arg"),
+                     std::filesystem::path{"/tmp/aba/sadf/aksk/annsp"}, "arg"),
                  clapp::path_does_not_exist_t);
 }
 
diff --git a/usage/main.cpp b/usage/main.cpp
index cf3a0e61..2875b4ce 100644
--- a/usage/main.cpp
+++ b/usage/main.cpp
@@ -1,7 +1,6 @@
 #include <clapp/argument.h>
 #include <clapp/build_info.h>
 #include <clapp/exception.h>
-#include <clapp/filesystem.h>
 #include <clapp/main_parser.h>
 #include <clapp/option.h>
 #include <clapp/parser.h>
-- 
GitLab