From 043813478ad01262c9245441892bc19b95d1ba5c Mon Sep 17 00:00:00 2001 From: Lars Toenning Date: Fri, 26 Jan 2024 23:05:38 +0100 Subject: [PATCH] refactor: Remove unused library path helper --- src/blackmisc/CMakeLists.txt | 2 - src/blackmisc/librarypath.cpp | 40 ---------------- src/blackmisc/librarypath.h | 28 ----------- tests/blackmisc/CMakeLists.txt | 6 --- .../testlibrarypath/testlibrarypath.cpp | 48 ------------------- 5 files changed, 124 deletions(-) delete mode 100644 src/blackmisc/librarypath.cpp delete mode 100644 src/blackmisc/librarypath.h delete mode 100644 tests/blackmisc/testlibrarypath/testlibrarypath.cpp diff --git a/src/blackmisc/CMakeLists.txt b/src/blackmisc/CMakeLists.txt index 3194d25c3..bb1b6f808 100644 --- a/src/blackmisc/CMakeLists.txt +++ b/src/blackmisc/CMakeLists.txt @@ -249,8 +249,6 @@ add_library(misc SHARED json.h jsonexception.cpp jsonexception.h - librarypath.cpp - librarypath.h lockfree.h logcategories.h logcategory.cpp diff --git a/src/blackmisc/librarypath.cpp b/src/blackmisc/librarypath.cpp deleted file mode 100644 index 659ca8941..000000000 --- a/src/blackmisc/librarypath.cpp +++ /dev/null @@ -1,40 +0,0 @@ -// SPDX-FileCopyrightText: Copyright (C) 2016 swift Project Community / Contributors -// SPDX-License-Identifier: GPL-3.0-or-later OR LicenseRef-swift-pilot-client-1 - -#include "blackmisc/librarypath.h" -#include -#include -#include - -#ifdef Q_OS_WIN -# include -#endif - -namespace BlackMisc -{ - - void setCustomLibraryPath(const QString &path) - { -#ifdef Q_OS_WIN - std::wstring customLibraryPath = path.toStdWString(); - SetDllDirectory(customLibraryPath.data()); -#else - Q_UNUSED(path); - // do nothing. -#endif - } - - QString getCustomLibraryPath() - { -#ifdef Q_OS_WIN - const DWORD nBufferLength = GetDllDirectory(0, nullptr); - std::vector customLibraryPath(nBufferLength); - GetDllDirectory(nBufferLength, customLibraryPath.data()); - return QString::fromWCharArray(customLibraryPath.data()); -#else - // do nothing. - return {}; -#endif - } - -} // ns diff --git a/src/blackmisc/librarypath.h b/src/blackmisc/librarypath.h deleted file mode 100644 index bb0c1971d..000000000 --- a/src/blackmisc/librarypath.h +++ /dev/null @@ -1,28 +0,0 @@ -// SPDX-FileCopyrightText: Copyright (C) 2016 swift Project Community / Contributors -// SPDX-License-Identifier: GPL-3.0-or-later OR LicenseRef-swift-pilot-client-1 - -//! \file - -#ifndef BLACKMISC_LIBRARYPATH_H -#define BLACKMISC_LIBRARYPATH_H - -#include "blackmisc/blackmiscexport.h" - -namespace BlackMisc -{ - - //! Sets the custom path to additionally search when loading libraries. - //! This does not change the default search paths. - //! \warning This is currently Windows only. Use rpath on Unix. - //! \sa getCustomLibraryPath - BLACKMISC_EXPORT void setCustomLibraryPath(const QString &path); - - //! Get the custom path to search when loading libraries. - //! Returns an empty string when no custom library path is set. - //! \note This will not return the default search path. - //! \warning This is currently Windows only. Use rpath on Unix. - BLACKMISC_EXPORT QString getCustomLibraryPath(); - -} // ns - -#endif // guard diff --git a/tests/blackmisc/CMakeLists.txt b/tests/blackmisc/CMakeLists.txt index 34bf4b1eb..511c0943d 100644 --- a/tests/blackmisc/CMakeLists.txt +++ b/tests/blackmisc/CMakeLists.txt @@ -138,12 +138,6 @@ add_swift_test( LINK_LIBRARIES misc tests_test Qt::Core ) -add_swift_test( - NAME misc_librarypath - SOURCES testlibrarypath/testlibrarypath.cpp - LINK_LIBRARIES blackconfig misc tests_test Qt::Core -) - add_swift_test( NAME misc_process SOURCES testprocess/testprocess.cpp diff --git a/tests/blackmisc/testlibrarypath/testlibrarypath.cpp b/tests/blackmisc/testlibrarypath/testlibrarypath.cpp deleted file mode 100644 index 09e5d53d3..000000000 --- a/tests/blackmisc/testlibrarypath/testlibrarypath.cpp +++ /dev/null @@ -1,48 +0,0 @@ -// SPDX-FileCopyrightText: Copyright (C) 2016 swift Project Community / Contributors -// SPDX-License-Identifier: GPL-3.0-or-later OR LicenseRef-swift-pilot-client-1 - -//! \cond PRIVATE_TESTS -//! \file -//! \ingroup testblackmisc - -#include "blackconfig/buildconfig.h" -#include "blackmisc/librarypath.h" -#include "test.h" - -#include - -namespace BlackMiscTest -{ - //! Geo classes tests - class CTestLibraryPath : public QObject - { - Q_OBJECT - - private slots: - //! Basic unit tests for library path - void libraryPath(); - }; - - void CTestLibraryPath::libraryPath() - { - if (!BlackConfig::CBuildConfig::isRunningOnWindowsNtPlatform()) { return; } - - auto emptyPath = BlackMisc::getCustomLibraryPath(); - QVERIFY2(emptyPath.isEmpty(), "Default path should be empty"); - - QString customLibraryPath("c:\test"); - BlackMisc::setCustomLibraryPath(customLibraryPath); - QVERIFY2(BlackMisc::getCustomLibraryPath() == customLibraryPath, "setLibraryPath failed"); - - BlackMisc::setCustomLibraryPath(emptyPath); - QVERIFY2(emptyPath.isEmpty(), "Path should be empty again."); - } - -} // namespace - -//! main -BLACKTEST_MAIN(BlackMiscTest::CTestLibraryPath); - -#include "testlibrarypath.moc" - -//! \endcond