diff --git a/repertory/librepertory/include/platform/platform.hpp b/repertory/librepertory/include/platform/platform.hpp index 743a3587..e0015ab3 100644 --- a/repertory/librepertory/include/platform/platform.hpp +++ b/repertory/librepertory/include/platform/platform.hpp @@ -22,6 +22,12 @@ #ifndef REPERTORY_INCLUDE_PLATFORM_PLATFORM_HPP_ #define REPERTORY_INCLUDE_PLATFORM_PLATFORM_HPP_ +#include "types/repertory.hpp" + +namespace repertory { +[[nodiscard]] auto create_lock_id(provider_type prov, std::string unique_id); +} + #if defined(_WIN32) #include "platform/win32_platform.hpp" #include "utils/windows.hpp" diff --git a/repertory/librepertory/include/platform/unix_platform.hpp b/repertory/librepertory/include/platform/unix_platform.hpp index 38a0c117..a2595aa8 100644 --- a/repertory/librepertory/include/platform/unix_platform.hpp +++ b/repertory/librepertory/include/platform/unix_platform.hpp @@ -26,8 +26,6 @@ #include "types/repertory.hpp" namespace repertory { -[[nodiscard]] auto create_lock_id(provider_type prov, std::string unique_id); - class i_provider; class lock_data final { diff --git a/repertory/librepertory/include/platform/win32_platform.hpp b/repertory/librepertory/include/platform/win32_platform.hpp index 01d4494c..628a0d06 100644 --- a/repertory/librepertory/include/platform/win32_platform.hpp +++ b/repertory/librepertory/include/platform/win32_platform.hpp @@ -26,8 +26,6 @@ #include "types/repertory.hpp" namespace repertory { -[[nodiscard]] auto create_lock_id(provider_type prov, std::string unique_id); - class i_provider; class lock_data final { @@ -42,7 +40,6 @@ public: auto operator=(lock_data &&) -> lock_data & = delete; private: - provider_type prov_; std::string mutex_id_; HANDLE mutex_handle_{INVALID_HANDLE_VALUE}; DWORD mutex_state_{WAIT_FAILED}; diff --git a/repertory/librepertory/src/platform/unix_platform.cpp b/repertory/librepertory/src/platform/unix_platform.cpp index 1010ec0b..cd8421b0 100644 --- a/repertory/librepertory/src/platform/unix_platform.cpp +++ b/repertory/librepertory/src/platform/unix_platform.cpp @@ -21,7 +21,7 @@ */ #if !defined(_WIN32) -#include "platform/unix_platform.hpp" +#include "platform/platform.hpp" #include "app_config.hpp" #include "events/event_system.hpp" @@ -36,11 +36,6 @@ #include "utils/unix.hpp" namespace repertory { -auto create_lock_id(provider_type prov, std::string unique_id) { - return fmt::format("{}_{}_{}", REPERTORY_DATA_NAME, - app_config::get_provider_name(prov), unique_id); -} - lock_data::lock_data(const provider_type &prov, std::string unique_id) : mutex_id_(create_lock_id(prov, unique_id)) { lock_fd_ = open(get_lock_file().c_str(), O_CREAT | O_RDWR, S_IWUSR | S_IRUSR); diff --git a/repertory/librepertory/src/platform/win32_platform.cpp b/repertory/librepertory/src/platform/win32_platform.cpp index 31be0317..547644f5 100644 --- a/repertory/librepertory/src/platform/win32_platform.cpp +++ b/repertory/librepertory/src/platform/win32_platform.cpp @@ -21,9 +21,8 @@ */ #if defined(_WIN32) -#include "platform/win32_platform.hpp" +#include "platform/platform.hpp" -#include "app_config.hpp" #include "events/event_system.hpp" #include "events/types/filesystem_item_added.hpp" #include "providers/i_provider.hpp" @@ -32,19 +31,13 @@ #include "utils/string.hpp" namespace repertory { -auto create_lock_id(provider_type prov, std::string unique_id) { - return fmt::format("{}_{}_{}", REPERTORY_DATA_NAME, - app_config::get_provider_name(prov), unique_id); -} - -lock_data::~lock_data() { release(); } - lock_data::lock_data(provider_type prov, std::string unique_id) - : prov_(prov), - mutex_id_(create_lock_id(prov, unique_id)), + : mutex_id_(create_lock_id(prov, unique_id)), mutex_handle_(::CreateMutex(nullptr, FALSE, create_lock_id(prov, unique_id).c_str())) {} +lock_data::~lock_data() { release(); } + auto lock_data::get_current_mount_state(json &mount_state) -> bool { REPERTORY_USES_FUNCTION_NAME(); diff --git a/repertory/librepertory/src/utils/platform.cpp b/repertory/librepertory/src/utils/platform.cpp new file mode 100644 index 00000000..41b82318 --- /dev/null +++ b/repertory/librepertory/src/utils/platform.cpp @@ -0,0 +1,31 @@ +/* + Copyright <2018-2025> + + Permission is hereby granted, free of charge, to any person obtaining a copy + of this software and associated documentation files (the "Software"), to deal + in the Software without restriction, including without limitation the rights + to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + copies of the Software, and to permit persons to whom the Software is + furnished to do so, subject to the following conditions: + + The above copyright notice and this permission notice shall be included in all + copies or substantial portions of the Software. + + 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. +*/ +#include "platform/platform.hpp" + +#include "app_config.hpp" + +namespace repertory { +auto create_lock_id(provider_type prov, std::string unique_id) { + return fmt::format("{}_{}_{}", REPERTORY_DATA_NAME, + app_config::get_provider_name(prov), unique_id); +} +} // namespace repertory