Use `fs` consistently over `std::filesystem` 43/320443/1
authorMichal Bloch <m.bloch@samsung.com>
Thu, 27 Feb 2025 19:03:39 +0000 (20:03 +0100)
committerMichal Bloch <m.bloch@samsung.com>
Thu, 27 Feb 2025 19:17:08 +0000 (20:17 +0100)
Change-Id: Id743bce0383e30cc0d5961f22c12c45ad63f2e80

src/service/src/dir_backend.hpp
src/service/src/dir_backend_fixed_size.cpp
src/service/src/dir_backend_fixed_size.hpp
src/service/src/dir_backend_regular_dir.cpp
src/service/src/dir_backend_regular_dir.hpp
src/service/src/fs_helpers.cpp

index a2bff2e584ed84abba4f1f9213929d18a2c245d7..d1c66c5cc41935fe4f1842639fda842a14e188a2 100644 (file)
@@ -5,9 +5,9 @@
 namespace fs = std::filesystem;
 
 struct DirBackend {
-       virtual void RemoveSubsession (const std::filesystem::path& subsession_path) const = 0;
-       virtual void SwitchSubsessionAway (const std::filesystem::path& subsession_path) const = 0;
-       virtual void SwitchSubsessionInto (const std::filesystem::path& subsession_path) const = 0;
+       virtual void RemoveSubsession (const fs::path& subsession_path) const = 0;
+       virtual void SwitchSubsessionAway (const fs::path& subsession_path) const = 0;
+       virtual void SwitchSubsessionInto (const fs::path& subsession_path) const = 0;
 };
 
 struct DirBackendAdd {
index 067e4a9814e1cee0a92e3fad1de26f47ec2e04b4..6818a024741f6dcfe55210fb8c5630d1b1b39285 100644 (file)
@@ -33,7 +33,6 @@
 
 #include <string_view>
 
-namespace fs = std::filesystem;
 using namespace std::literals;
 
 // Should be unique per-backend.
@@ -212,14 +211,14 @@ void DirBackendFixedSize::RemoveSubsession (const fs::path& subsession_path) con
        fs::remove(image_path);
 }
 
-void DirBackendFixedSize::SwitchSubsessionAway (const std::filesystem::path& subsession_path) const
+void DirBackendFixedSize::SwitchSubsessionAway (const fs::path& subsession_path) const
 {
        /* Note, we cannot keep the subsession mounted permanently,
         * from Add until Remove, because reboots happen. */
        do_umount(subsession_path);
 }
 
-void DirBackendFixedSize::SwitchSubsessionInto (const std::filesystem::path& subsession_path) const
+void DirBackendFixedSize::SwitchSubsessionInto (const fs::path& subsession_path) const
 {
        const auto image_path = GetImagePathFromSubsessionPath(subsession_path);
 
index 34bff07b6da6afb901c136db0e35249ff6834dd5..cd752921d35bd17d9583a1d6e082bab01be7b9df 100644 (file)
@@ -4,8 +4,6 @@
 
 #include <cstdint>
 
-namespace fs = std::filesystem;
-
 struct DirBackendFixedSize : public DirBackend {
        void RemoveSubsession (const fs::path& subsession_path) const override;
        void SwitchSubsessionAway (const fs::path& subsession_path) const override;
index 8c4dcfd94ed1889e0f959744f1c732903e87f647..5f46a7f946fff456721f845f340ab77e014a2edc 100644 (file)
@@ -23,7 +23,6 @@
 #include "dir_backend_regular_dir.hpp"
 #include "os_ops.hpp"
 
-namespace fs = std::filesystem;
 using namespace std::string_literals;
 
 fs::path DirBackendAddRegularDir::AddSubsessionPrepare (const fs::path& subsession_path, int uid, int gid) const
@@ -72,10 +71,10 @@ void DirBackendRegularDir::RemoveSubsession (const fs::path& subsession_path) co
        fs::remove_all(tmp_subsession_path);
 }
 
-void DirBackendRegularDir::SwitchSubsessionAway (const std::filesystem::path& subsession_path) const
+void DirBackendRegularDir::SwitchSubsessionAway (const fs::path& subsession_path) const
 {
 }
 
-void DirBackendRegularDir::SwitchSubsessionInto (const std::filesystem::path& subsession_path) const
+void DirBackendRegularDir::SwitchSubsessionInto (const fs::path& subsession_path) const
 {
 }
index fc3ff69797f369c960fdadd2266ef1199c1cc33f..ed4a9f612077af4db094b6254a8ac5e0da5fb63d 100644 (file)
@@ -3,9 +3,9 @@
 #include "dir_backend.hpp"
 
 struct DirBackendRegularDir : public DirBackend {
-       void RemoveSubsession (const std::filesystem::path& subsession_path) const override;
-       void SwitchSubsessionAway (const std::filesystem::path& subsession_path) const override;
-       void SwitchSubsessionInto (const std::filesystem::path& subsession_path) const override;
+       void RemoveSubsession (const fs::path& subsession_path) const override;
+       void SwitchSubsessionAway (const fs::path& subsession_path) const override;
+       void SwitchSubsessionInto (const fs::path& subsession_path) const override;
 };
 
 struct DirBackendAddRegularDir : public DirBackendAdd {
index 091c87c03c5ea0fd7789dee51d876779194caeb0..fb6938200ade95dce9a06c86f5afaa1003273bdb 100644 (file)
@@ -59,7 +59,7 @@ static inline bool should_copy_perms_from_skel(Directory_Class type) {
 }
 
 // Create `$HOME/subsession` directory if it doesn't exist
-static void create_main_subdirectory(const int session_uid, fs::path main_dir)
+static void create_main_subdirectory(const int session_uid, const fs::path& main_dir)
 {
        if (fs::exists(main_dir))
                return;