refactor: remove ArchFile::getbasePath for QFileInfo::fileName
This commit is contained in:
parent
c1a7b836ce
commit
516f803eb4
9 changed files with 10 additions and 49 deletions
|
|
@ -21,12 +21,6 @@ public:
|
||||||
//! @name manipulators
|
//! @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
|
//! Get installed directory
|
||||||
/*!
|
/*!
|
||||||
Returns the directory in which Deskflow is installed.
|
Returns the directory in which Deskflow is installed.
|
||||||
|
|
|
||||||
|
|
@ -29,20 +29,6 @@ ArchFileUnix::~ArchFileUnix()
|
||||||
// do nothing
|
// 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()
|
std::string ArchFileUnix::getInstalledDirectory()
|
||||||
{
|
{
|
||||||
#if WINAPI_XWINDOWS
|
#if WINAPI_XWINDOWS
|
||||||
|
|
|
||||||
|
|
@ -19,6 +19,5 @@ public:
|
||||||
virtual ~ArchFileUnix();
|
virtual ~ArchFileUnix();
|
||||||
|
|
||||||
// IArchFile overrides
|
// IArchFile overrides
|
||||||
virtual const char *getBasename(const char *pathname);
|
|
||||||
virtual std::string getInstalledDirectory();
|
virtual std::string getInstalledDirectory();
|
||||||
};
|
};
|
||||||
|
|
|
||||||
|
|
@ -27,29 +27,6 @@ ArchFileWindows::~ArchFileWindows()
|
||||||
// do nothing
|
// 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()
|
std::string ArchFileWindows::getInstalledDirectory()
|
||||||
{
|
{
|
||||||
char fileNameBuffer[MAX_PATH];
|
char fileNameBuffer[MAX_PATH];
|
||||||
|
|
|
||||||
|
|
@ -19,6 +19,5 @@ public:
|
||||||
virtual ~ArchFileWindows();
|
virtual ~ArchFileWindows();
|
||||||
|
|
||||||
// IArchFile overrides
|
// IArchFile overrides
|
||||||
virtual const char *getBasename(const char *pathname);
|
|
||||||
virtual std::string getInstalledDirectory();
|
virtual std::string getInstalledDirectory();
|
||||||
};
|
};
|
||||||
|
|
|
||||||
|
|
@ -16,6 +16,8 @@
|
||||||
#include <VersionHelpers.h>
|
#include <VersionHelpers.h>
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#include <QFileInfo>
|
||||||
|
|
||||||
deskflow::ArgsBase *ArgParser::m_argsBase = nullptr;
|
deskflow::ArgsBase *ArgParser::m_argsBase = nullptr;
|
||||||
|
|
||||||
ArgParser::ArgParser(App *app) : m_app(app)
|
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)
|
void ArgParser::updateCommonArgs(const char *const *argv)
|
||||||
{
|
{
|
||||||
argsBase().m_name = ARCH->getHostName();
|
argsBase().m_name = ARCH->getHostName();
|
||||||
argsBase().m_pname = ARCH->getBasename(argv[0]);
|
argsBase().m_pname = QFileInfo(argv[0]).fileName().toLocal8Bit().constData();
|
||||||
}
|
}
|
||||||
|
|
||||||
bool ArgParser::checkUnexpectedArgs()
|
bool ArgParser::checkUnexpectedArgs()
|
||||||
|
|
|
||||||
|
|
@ -147,7 +147,7 @@ add_library(${lib_name} STATIC ${PLATFORM_CODE}
|
||||||
ipc/DaemonIpcServer.h
|
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)
|
if(WIN32)
|
||||||
target_compile_definitions(${lib_name} PUBLIC HAVE_WINTOAST)
|
target_compile_definitions(${lib_name} PUBLIC HAVE_WINTOAST)
|
||||||
|
|
|
||||||
|
|
@ -33,6 +33,8 @@
|
||||||
#include "platform/MSWindowsScreen.h"
|
#include "platform/MSWindowsScreen.h"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#include <QFileInfo> // Must include before XWindowsScreen to avoid conflicts with xlib.h
|
||||||
|
|
||||||
#if WINAPI_XWINDOWS
|
#if WINAPI_XWINDOWS
|
||||||
#include "platform/XWindowsScreen.h"
|
#include "platform/XWindowsScreen.h"
|
||||||
#endif
|
#endif
|
||||||
|
|
@ -504,7 +506,7 @@ int ClientApp::runInner(int argc, char **argv, StartupFunc startup)
|
||||||
{
|
{
|
||||||
// general initialization
|
// general initialization
|
||||||
m_serverAddress = new NetworkAddress;
|
m_serverAddress = new NetworkAddress;
|
||||||
args().m_pname = ARCH->getBasename(argv[0]);
|
args().m_pname = QFileInfo(argv[0]).fileName().toLocal8Bit().constData();
|
||||||
|
|
||||||
int result;
|
int result;
|
||||||
try {
|
try {
|
||||||
|
|
|
||||||
|
|
@ -58,6 +58,8 @@
|
||||||
#include "mt/Thread.h"
|
#include "mt/Thread.h"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#include <QFileInfo>
|
||||||
|
|
||||||
#include <fstream>
|
#include <fstream>
|
||||||
#include <iostream>
|
#include <iostream>
|
||||||
#include <sstream>
|
#include <sstream>
|
||||||
|
|
@ -775,7 +777,7 @@ int ServerApp::runInner(int argc, char **argv, StartupFunc startup)
|
||||||
// general initialization
|
// general initialization
|
||||||
m_deskflowAddress = new NetworkAddress;
|
m_deskflowAddress = new NetworkAddress;
|
||||||
args().m_config = std::make_shared<Config>(m_events);
|
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
|
// run
|
||||||
int result = startup(argc, argv);
|
int result = startup(argc, argv);
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue