mirror of
https://github.com/debauchee/barrier.git
synced 2026-11-26 22:03:24 +08:00
Fixed: Plugins dir may change depending on user #4168
This commit is contained in:
@@ -20,6 +20,7 @@
|
||||
|
||||
#include "common/IInterface.h"
|
||||
#include "common/stdstring.h"
|
||||
#include "base/String.h"
|
||||
|
||||
//! Interface for architecture dependent file system operations
|
||||
/*!
|
||||
@@ -64,13 +65,16 @@ public:
|
||||
|
||||
//! Get plugins directory
|
||||
/*!
|
||||
Returns the plugin files directory.
|
||||
Returns the plugin files directory. If no plugin directory is set,
|
||||
this will return the plugin folder within the user's profile.
|
||||
*/
|
||||
virtual std::string getPluginDirectory() = 0;
|
||||
|
||||
//! Get local profile directory
|
||||
//! Get user's profile directory
|
||||
/*!
|
||||
Returns the local profile directory.
|
||||
Returns the user's profile directory. If no profile directory is set,
|
||||
this will return the user's profile according to the operating system,
|
||||
which will depend on which user launched the program.
|
||||
*/
|
||||
virtual std::string getProfileDirectory() = 0;
|
||||
|
||||
@@ -84,6 +88,18 @@ public:
|
||||
virtual std::string concatPath(
|
||||
const std::string& prefix,
|
||||
const std::string& suffix) = 0;
|
||||
|
||||
//@}
|
||||
//! Set the user's profile directory
|
||||
/*
|
||||
Returns the user's profile directory.
|
||||
*/
|
||||
virtual void setProfileDirectory(const String& s) = 0;
|
||||
|
||||
//@}
|
||||
//! Set the user's plugin directory
|
||||
/*
|
||||
Returns the user's plugin directory.
|
||||
*/
|
||||
virtual void setPluginDirectory(const String& s) = 0;
|
||||
};
|
||||
|
||||
@@ -107,6 +107,10 @@ ArchFileUnix::getLogDirectory()
|
||||
std::string
|
||||
ArchFileUnix::getPluginDirectory()
|
||||
{
|
||||
if (!m_pluginDirectory.empty()) {
|
||||
return m_pluginDirectory;
|
||||
}
|
||||
|
||||
#if WINAPI_XWINDOWS
|
||||
return getProfileDirectory().append("/plugins");
|
||||
#else
|
||||
@@ -117,11 +121,19 @@ ArchFileUnix::getPluginDirectory()
|
||||
std::string
|
||||
ArchFileUnix::getProfileDirectory()
|
||||
{
|
||||
String dir;
|
||||
if (!m_profileDirectory.empty()) {
|
||||
dir = m_profileDirectory;
|
||||
}
|
||||
else {
|
||||
#if WINAPI_XWINDOWS
|
||||
return getUserDirectory().append("/.synergy");
|
||||
dir = getUserDirectory().append("/.synergy");
|
||||
#else
|
||||
return getUserDirectory().append("/Library/Synergy");
|
||||
dir = getUserDirectory().append("/Library/Synergy");
|
||||
#endif
|
||||
}
|
||||
return dir;
|
||||
|
||||
}
|
||||
|
||||
std::string
|
||||
@@ -137,3 +149,15 @@ ArchFileUnix::concatPath(const std::string& prefix,
|
||||
path += suffix;
|
||||
return path;
|
||||
}
|
||||
|
||||
void
|
||||
ArchFileUnix::setProfileDirectory(const String& s)
|
||||
{
|
||||
m_profileDirectory = s;
|
||||
}
|
||||
|
||||
void
|
||||
ArchFileUnix::setPluginDirectory(const String& s)
|
||||
{
|
||||
m_pluginDirectory = s;
|
||||
}
|
||||
|
||||
@@ -38,4 +38,10 @@ public:
|
||||
virtual std::string getProfileDirectory();
|
||||
virtual std::string concatPath(const std::string& prefix,
|
||||
const std::string& suffix);
|
||||
virtual void setProfileDirectory(const String& s);
|
||||
virtual void setPluginDirectory(const String& s);
|
||||
|
||||
private:
|
||||
String m_profileDirectory;
|
||||
String m_pluginDirectory;
|
||||
};
|
||||
|
||||
@@ -142,6 +142,10 @@ ArchFileWindows::getLogDirectory()
|
||||
std::string
|
||||
ArchFileWindows::getPluginDirectory()
|
||||
{
|
||||
if (!m_pluginDirectory.empty()) {
|
||||
return m_pluginDirectory;
|
||||
}
|
||||
|
||||
std::string dir = getProfileDirectory();
|
||||
dir.append("\\Plugins");
|
||||
return dir;
|
||||
@@ -150,16 +154,23 @@ ArchFileWindows::getPluginDirectory()
|
||||
std::string
|
||||
ArchFileWindows::getProfileDirectory()
|
||||
{
|
||||
TCHAR result[MAX_PATH];
|
||||
std::string dir;
|
||||
if (SUCCEEDED(SHGetFolderPath(NULL, CSIDL_LOCAL_APPDATA, NULL, 0, result))) {
|
||||
dir = result;
|
||||
String dir;
|
||||
if (!m_profileDirectory.empty()) {
|
||||
dir = m_profileDirectory;
|
||||
}
|
||||
else {
|
||||
dir = getUserDirectory();
|
||||
TCHAR result[MAX_PATH];
|
||||
if (SUCCEEDED(SHGetFolderPath(NULL, CSIDL_LOCAL_APPDATA, NULL, 0, result))) {
|
||||
dir = result;
|
||||
}
|
||||
else {
|
||||
dir = getUserDirectory();
|
||||
}
|
||||
}
|
||||
|
||||
// HACK: append program name, this seems wrong.
|
||||
dir.append("\\Synergy");
|
||||
|
||||
return dir;
|
||||
}
|
||||
|
||||
@@ -178,3 +189,15 @@ ArchFileWindows::concatPath(const std::string& prefix,
|
||||
path += suffix;
|
||||
return path;
|
||||
}
|
||||
|
||||
void
|
||||
ArchFileWindows::setProfileDirectory(const String& s)
|
||||
{
|
||||
m_profileDirectory = s;
|
||||
}
|
||||
|
||||
void
|
||||
ArchFileWindows::setPluginDirectory(const String& s)
|
||||
{
|
||||
m_pluginDirectory = s;
|
||||
}
|
||||
|
||||
@@ -38,4 +38,10 @@ public:
|
||||
virtual std::string getProfileDirectory();
|
||||
virtual std::string concatPath(const std::string& prefix,
|
||||
const std::string& suffix);
|
||||
virtual void setProfileDirectory(const String& s);
|
||||
virtual void setPluginDirectory(const String& s);
|
||||
|
||||
private:
|
||||
String m_profileDirectory;
|
||||
String m_pluginDirectory;
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user