mirror of
https://github.com/swift-project/pilotclient.git
synced 2026-08-09 02:56:01 +08:00
refactor: Remove unused library path helper
This commit is contained in:
@@ -249,8 +249,6 @@ add_library(misc SHARED
|
||||
json.h
|
||||
jsonexception.cpp
|
||||
jsonexception.h
|
||||
librarypath.cpp
|
||||
librarypath.h
|
||||
lockfree.h
|
||||
logcategories.h
|
||||
logcategory.cpp
|
||||
|
||||
@@ -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 <QtGlobal>
|
||||
#include <QString>
|
||||
#include <vector>
|
||||
|
||||
#ifdef Q_OS_WIN
|
||||
# include <windows.h>
|
||||
#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<wchar_t> customLibraryPath(nBufferLength);
|
||||
GetDllDirectory(nBufferLength, customLibraryPath.data());
|
||||
return QString::fromWCharArray(customLibraryPath.data());
|
||||
#else
|
||||
// do nothing.
|
||||
return {};
|
||||
#endif
|
||||
}
|
||||
|
||||
} // ns
|
||||
@@ -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
|
||||
@@ -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
|
||||
|
||||
@@ -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 <QTest>
|
||||
|
||||
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
|
||||
Reference in New Issue
Block a user