refactor: remove ArchFile::getbasePath for QFileInfo::fileName

This commit is contained in:
sithlord48
2025-03-22 08:52:26 -04:00
committed by Nick Bolton
parent c1a7b836ce
commit 516f803eb4
9 changed files with 10 additions and 49 deletions

View File

@ -21,12 +21,6 @@ public:
//! @name manipulators
//@{
//! Extract base name
/*!
Find the base name in the given \c pathname.
*/
virtual const char *getBasename(const char *pathname) = 0;
//! Get installed directory
/*!
Returns the directory in which Deskflow is installed.

View File

@ -29,20 +29,6 @@ ArchFileUnix::~ArchFileUnix()
// do nothing
}
const char *ArchFileUnix::getBasename(const char *pathname)
{
if (pathname == NULL) {
return NULL;
}
const char *basename = strrchr(pathname, '/');
if (basename != NULL) {
return basename + 1;
} else {
return pathname;
}
}
std::string ArchFileUnix::getInstalledDirectory()
{
#if WINAPI_XWINDOWS

View File

@ -19,6 +19,5 @@ public:
virtual ~ArchFileUnix();
// IArchFile overrides
virtual const char *getBasename(const char *pathname);
virtual std::string getInstalledDirectory();
};

View File

@ -27,29 +27,6 @@ ArchFileWindows::~ArchFileWindows()
// do nothing
}
const char *ArchFileWindows::getBasename(const char *pathname)
{
if (pathname == NULL) {
return NULL;
}
// check for last slash
const char *basename = strrchr(pathname, '/');
if (basename != NULL) {
++basename;
} else {
basename = pathname;
}
// check for last backslash
const char *basename2 = strrchr(pathname, '\\');
if (basename2 != NULL && basename2 > basename) {
basename = basename2 + 1;
}
return basename;
}
std::string ArchFileWindows::getInstalledDirectory()
{
char fileNameBuffer[MAX_PATH];

View File

@ -19,6 +19,5 @@ public:
virtual ~ArchFileWindows();
// IArchFile overrides
virtual const char *getBasename(const char *pathname);
virtual std::string getInstalledDirectory();
};

View File

@ -16,6 +16,8 @@
#include <VersionHelpers.h>
#endif
#include <QFileInfo>
deskflow::ArgsBase *ArgParser::m_argsBase = nullptr;
ArgParser::ArgParser(App *app) : m_app(app)
@ -388,7 +390,7 @@ ArgParser::assembleCommand(std::vector<std::string> &argsArray, std::string igno
void ArgParser::updateCommonArgs(const char *const *argv)
{
argsBase().m_name = ARCH->getHostName();
argsBase().m_pname = ARCH->getBasename(argv[0]);
argsBase().m_pname = QFileInfo(argv[0]).fileName().toLocal8Bit().constData();
}
bool ArgParser::checkUnexpectedArgs()

View File

@ -147,7 +147,7 @@ add_library(${lib_name} STATIC ${PLATFORM_CODE}
ipc/DaemonIpcServer.h
)
target_link_libraries(${lib_name} PRIVATE Qt6::Core Qt6::Network)
target_link_libraries(${lib_name} PUBLIC Qt6::Core Qt6::Network)
if(WIN32)
target_compile_definitions(${lib_name} PUBLIC HAVE_WINTOAST)

View File

@ -33,6 +33,8 @@
#include "platform/MSWindowsScreen.h"
#endif
#include <QFileInfo> // Must include before XWindowsScreen to avoid conflicts with xlib.h
#if WINAPI_XWINDOWS
#include "platform/XWindowsScreen.h"
#endif
@ -504,7 +506,7 @@ int ClientApp::runInner(int argc, char **argv, StartupFunc startup)
{
// general initialization
m_serverAddress = new NetworkAddress;
args().m_pname = ARCH->getBasename(argv[0]);
args().m_pname = QFileInfo(argv[0]).fileName().toLocal8Bit().constData();
int result;
try {

View File

@ -58,6 +58,8 @@
#include "mt/Thread.h"
#endif
#include <QFileInfo>
#include <fstream>
#include <iostream>
#include <sstream>
@ -775,7 +777,7 @@ int ServerApp::runInner(int argc, char **argv, StartupFunc startup)
// general initialization
m_deskflowAddress = new NetworkAddress;
args().m_config = std::make_shared<Config>(m_events);
args().m_pname = ARCH->getBasename(argv[0]);
args().m_pname = QFileInfo(argv[0]).fileName().toLocal8Bit().constData();
// run
int result = startup(argc, argv);