fix: store IPC file in application directory (#5226)
This commit is contained in:
@@ -13,6 +13,7 @@
|
||||
#include "singletons/Settings.hpp"
|
||||
#include "singletons/Updates.hpp"
|
||||
#include "util/AttachToConsole.hpp"
|
||||
#include "util/IpcQueue.hpp"
|
||||
|
||||
#include <QApplication>
|
||||
#include <QCommandLineParser>
|
||||
@@ -62,6 +63,7 @@ int main(int argc, char **argv)
|
||||
box.exec();
|
||||
return 1;
|
||||
}
|
||||
ipc::initPaths(paths.get());
|
||||
|
||||
const Args args(a, *paths);
|
||||
|
||||
|
||||
@@ -140,6 +140,13 @@ void Paths::initSubDirectories()
|
||||
this->pluginsDirectory = makePath("Plugins");
|
||||
this->themesDirectory = makePath("Themes");
|
||||
this->crashdumpDirectory = makePath("Crashes");
|
||||
#ifdef Q_OS_WIN
|
||||
this->ipcDirectory = makePath("IPC");
|
||||
#else
|
||||
// NOTE: We do *NOT* use IPC on non-Windows platforms.
|
||||
// If we start, we should re-consider this directory.
|
||||
this->ipcDirectory = "/tmp";
|
||||
#endif
|
||||
}
|
||||
|
||||
} // namespace chatterino
|
||||
|
||||
@@ -39,6 +39,11 @@ public:
|
||||
// Custom themes live here. <appDataDirectory>/Themes
|
||||
QString themesDirectory;
|
||||
|
||||
// Directory for shared memory files.
|
||||
// <appDataDirectory>/IPC on Windows
|
||||
// /tmp elsewhere
|
||||
QString ipcDirectory;
|
||||
|
||||
bool createFolder(const QString &folderPath);
|
||||
[[deprecated("use Modes::instance().portable instead")]] bool isPortable()
|
||||
const;
|
||||
|
||||
@@ -1,7 +1,9 @@
|
||||
#include "util/IpcQueue.hpp"
|
||||
|
||||
#include "common/QLogging.hpp"
|
||||
#include "singletons/Paths.hpp"
|
||||
|
||||
#define BOOST_INTERPROCESS_SHARED_DIR_FUNC
|
||||
#include <boost/interprocess/ipc/message_queue.hpp>
|
||||
#include <QByteArray>
|
||||
#include <QString>
|
||||
@@ -9,8 +11,49 @@
|
||||
|
||||
namespace boost_ipc = boost::interprocess;
|
||||
|
||||
namespace {
|
||||
|
||||
static const chatterino::Paths *PATHS = nullptr;
|
||||
|
||||
} // namespace
|
||||
|
||||
namespace boost::interprocess::ipcdetail {
|
||||
|
||||
void get_shared_dir(std::string &shared_dir)
|
||||
{
|
||||
if (!PATHS)
|
||||
{
|
||||
assert(false && "PATHS not set");
|
||||
qCCritical(chatterinoNativeMessage)
|
||||
<< "PATHS not set for shared directory";
|
||||
return;
|
||||
}
|
||||
shared_dir = PATHS->ipcDirectory.toStdString();
|
||||
}
|
||||
|
||||
#ifdef BOOST_INTERPROCESS_WINDOWS
|
||||
void get_shared_dir(std::wstring &shared_dir)
|
||||
{
|
||||
if (!PATHS)
|
||||
{
|
||||
assert(false && "PATHS not set");
|
||||
qCCritical(chatterinoNativeMessage)
|
||||
<< "PATHS not set for shared directory";
|
||||
return;
|
||||
}
|
||||
shared_dir = PATHS->ipcDirectory.toStdWString();
|
||||
}
|
||||
#endif
|
||||
|
||||
} // namespace boost::interprocess::ipcdetail
|
||||
|
||||
namespace chatterino::ipc {
|
||||
|
||||
void initPaths(const Paths *paths)
|
||||
{
|
||||
PATHS = paths;
|
||||
}
|
||||
|
||||
void sendMessage(const char *name, const QByteArray &data)
|
||||
{
|
||||
try
|
||||
|
||||
@@ -6,8 +6,16 @@
|
||||
class QByteArray;
|
||||
class QString;
|
||||
|
||||
namespace chatterino {
|
||||
|
||||
class Paths;
|
||||
|
||||
} // namespace chatterino
|
||||
|
||||
namespace chatterino::ipc {
|
||||
|
||||
void initPaths(const Paths *paths);
|
||||
|
||||
void sendMessage(const char *name, const QByteArray &data);
|
||||
|
||||
class IpcQueuePrivate;
|
||||
|
||||
Reference in New Issue
Block a user