From da06e975215e4df1beb236787db19019ceb4ce76 Mon Sep 17 00:00:00 2001 From: sithlord48 Date: Sat, 31 May 2025 12:48:21 -0400 Subject: [PATCH] build: remove unused platform/MSWindowsUtils --- src/lib/platform/CMakeLists.txt | 2 -- src/lib/platform/MSWindowsUtil.cpp | 44 ------------------------------ src/lib/platform/MSWindowsUtil.h | 30 -------------------- 3 files changed, 76 deletions(-) delete mode 100644 src/lib/platform/MSWindowsUtil.cpp delete mode 100644 src/lib/platform/MSWindowsUtil.h diff --git a/src/lib/platform/CMakeLists.txt b/src/lib/platform/CMakeLists.txt index 6cef127ce..beaa26bd5 100644 --- a/src/lib/platform/CMakeLists.txt +++ b/src/lib/platform/CMakeLists.txt @@ -48,8 +48,6 @@ if(WIN32) MSWindowsScreenSaver.h MSWindowsSession.cpp MSWindowsSession.h - MSWindowsUtil.cpp - MSWindowsUtil.h MSWindowsWatchdog.cpp MSWindowsWatchdog.h ) diff --git a/src/lib/platform/MSWindowsUtil.cpp b/src/lib/platform/MSWindowsUtil.cpp deleted file mode 100644 index d52914d4a..000000000 --- a/src/lib/platform/MSWindowsUtil.cpp +++ /dev/null @@ -1,44 +0,0 @@ -/* - * Deskflow -- mouse and keyboard sharing utility - * SPDX-FileCopyrightText: (C) 2012 - 2016 Symless Ltd. - * SPDX-FileCopyrightText: (C) 2004 Chris Schoeneman - * SPDX-License-Identifier: GPL-2.0-only WITH LicenseRef-OpenSSL-Exception - */ - -#include "platform/MSWindowsUtil.h" - -#include "base/String.h" - -#include - -// -// MSWindowsUtil -// - -std::string MSWindowsUtil::getString(HINSTANCE instance, DWORD id) -{ - char *msg = nullptr; - int n = LoadString(instance, id, reinterpret_cast(&msg), 0); - - if (n <= 0) { - return std::string(); - } - - return std::string(msg, n); -} - -std::string MSWindowsUtil::getErrorString(HINSTANCE hinstance, DWORD error, DWORD id) -{ - char *buffer; - if (FormatMessage( - FORMAT_MESSAGE_ALLOCATE_BUFFER | FORMAT_MESSAGE_IGNORE_INSERTS | FORMAT_MESSAGE_FROM_SYSTEM, 0, error, - MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT), (LPTSTR)&buffer, 0, nullptr - ) == 0) { - std::string errorString = deskflow::string::sprintf("%d", error); - return deskflow::string::format(getString(hinstance, id).c_str(), errorString.c_str()); - } else { - std::string result(buffer); - LocalFree(buffer); - return result; - } -} diff --git a/src/lib/platform/MSWindowsUtil.h b/src/lib/platform/MSWindowsUtil.h deleted file mode 100644 index ee8a68d40..000000000 --- a/src/lib/platform/MSWindowsUtil.h +++ /dev/null @@ -1,30 +0,0 @@ -/* - * Deskflow -- mouse and keyboard sharing utility - * SPDX-FileCopyrightText: (C) 2012 - 2016 Symless Ltd. - * SPDX-FileCopyrightText: (C) 2004 Chris Schoeneman - * SPDX-License-Identifier: GPL-2.0-only WITH LicenseRef-OpenSSL-Exception - */ - -#pragma once - -#include - -#define WINDOWS_LEAN_AND_MEAN -#include - -class MSWindowsUtil -{ -public: - //! Get message string - /*! - Gets a string for \p id from the string table of \p instance. - */ - static std::string getString(HINSTANCE instance, DWORD id); - - //! Get error string - /*! - Gets a system error message for \p error. If the error cannot be - found return the string for \p id, replacing ${1} with \p error. - */ - static std::string getErrorString(HINSTANCE, DWORD error, DWORD id); -};