src: specify if file or directory path is returned by helpers (#1146)
This commit is contained in:
@@ -109,10 +109,10 @@ std::string Application::getUUID()
|
||||
|
||||
void Application::loadSettings()
|
||||
{
|
||||
MessageStatus(L"Load settings: " + UserPaths::getAppSettingsPath().wstr()).dispatch();
|
||||
MessageStatus(L"Load settings: " + UserPaths::getAppSettingsFilePath().wstr()).dispatch();
|
||||
|
||||
std::shared_ptr<ApplicationSettings> settings = ApplicationSettings::getInstance();
|
||||
settings->load(UserPaths::getAppSettingsPath());
|
||||
settings->load(UserPaths::getAppSettingsFilePath());
|
||||
|
||||
LogManager::getInstance()->setLoggingEnabled(settings->getLoggingEnabled());
|
||||
Logger* logger = LogManager::getInstance()->getLoggerByType("FileLogger");
|
||||
@@ -464,7 +464,7 @@ void Application::updateRecentProjects(const FilePath& projectSettingsFilePath)
|
||||
}
|
||||
|
||||
appSettings->setRecentProjects(recentProjects);
|
||||
appSettings->save(UserPaths::getAppSettingsPath());
|
||||
appSettings->save(UserPaths::getAppSettingsFilePath());
|
||||
|
||||
m_mainView->updateRecentProjectMenu();
|
||||
}
|
||||
|
||||
@@ -1,43 +1,45 @@
|
||||
#include "AppPath.h"
|
||||
|
||||
FilePath AppPath::m_sharedDataPath(L"");
|
||||
FilePath AppPath::m_cxxIndexerPath(L"");
|
||||
#include "utilityApp.h"
|
||||
|
||||
FilePath AppPath::getSharedDataPath()
|
||||
FilePath AppPath::s_sharedDataDirectoryPath(L"");
|
||||
FilePath AppPath::s_cxxIndexerDirectoryPath(L"");
|
||||
|
||||
FilePath AppPath::getSharedDataDirectoryPath()
|
||||
{
|
||||
return m_sharedDataPath;
|
||||
return s_sharedDataDirectoryPath;
|
||||
}
|
||||
|
||||
bool AppPath::setSharedDataPath(const FilePath& path)
|
||||
bool AppPath::setSharedDataDirectoryPath(const FilePath& path)
|
||||
{
|
||||
if (!path.empty())
|
||||
{
|
||||
m_sharedDataPath = path;
|
||||
s_sharedDataDirectoryPath = path;
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
FilePath AppPath::getCxxIndexerPath()
|
||||
FilePath AppPath::getCxxIndexerFilePath()
|
||||
{
|
||||
#if _WIN32
|
||||
const std::wstring cxxIndexerName(L"sourcetrail_indexer.exe");
|
||||
#else
|
||||
const std::wstring cxxIndexerName(L"sourcetrail_indexer");
|
||||
#endif
|
||||
|
||||
if (!m_cxxIndexerPath.empty())
|
||||
std::wstring cxxIndexerName(L"sourcetrail_indexer");
|
||||
if (utility::getOsType() == OS_WINDOWS)
|
||||
{
|
||||
return m_cxxIndexerPath.getConcatenated(cxxIndexerName);
|
||||
cxxIndexerName = L"sourcetrail_indexer.exe";
|
||||
}
|
||||
return m_sharedDataPath.getConcatenated(cxxIndexerName);
|
||||
|
||||
if (!s_cxxIndexerDirectoryPath.empty())
|
||||
{
|
||||
return s_cxxIndexerDirectoryPath.getConcatenated(cxxIndexerName);
|
||||
}
|
||||
return s_sharedDataDirectoryPath.getConcatenated(cxxIndexerName);
|
||||
}
|
||||
|
||||
bool AppPath::setCxxIndexerPath(const FilePath& path)
|
||||
bool AppPath::setCxxIndexerDirectoryPath(const FilePath& path)
|
||||
{
|
||||
if (!path.empty())
|
||||
{
|
||||
m_cxxIndexerPath = path;
|
||||
s_cxxIndexerDirectoryPath = path;
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
|
||||
@@ -6,15 +6,15 @@
|
||||
class AppPath
|
||||
{
|
||||
public:
|
||||
static FilePath getSharedDataPath();
|
||||
static bool setSharedDataPath(const FilePath& path);
|
||||
static FilePath getSharedDataDirectoryPath();
|
||||
static bool setSharedDataDirectoryPath(const FilePath& path);
|
||||
|
||||
static FilePath getCxxIndexerPath();
|
||||
static bool setCxxIndexerPath(const FilePath& path);
|
||||
static FilePath getCxxIndexerFilePath();
|
||||
static bool setCxxIndexerDirectoryPath(const FilePath& path);
|
||||
|
||||
private:
|
||||
static FilePath m_sharedDataPath;
|
||||
static FilePath m_cxxIndexerPath;
|
||||
static FilePath s_sharedDataDirectoryPath;
|
||||
static FilePath s_cxxIndexerDirectoryPath;
|
||||
};
|
||||
|
||||
#endif // APP_PATH_H
|
||||
|
||||
@@ -3,49 +3,49 @@
|
||||
#include "AppPath.h"
|
||||
#include "utilityApp.h"
|
||||
|
||||
FilePath ResourcePaths::getColorSchemesPath()
|
||||
FilePath ResourcePaths::getColorSchemesDirectoryPath()
|
||||
{
|
||||
return AppPath::getSharedDataPath().concatenate(L"data/color_schemes/");
|
||||
return AppPath::getSharedDataDirectoryPath().concatenate(L"data/color_schemes/");
|
||||
}
|
||||
|
||||
FilePath ResourcePaths::getSyntaxHighlightingRulesPath()
|
||||
FilePath ResourcePaths::getSyntaxHighlightingRulesDirectoryPath()
|
||||
{
|
||||
return AppPath::getSharedDataPath().concatenate(L"data/syntax_highlighting_rules/");
|
||||
return AppPath::getSharedDataDirectoryPath().concatenate(L"data/syntax_highlighting_rules/");
|
||||
}
|
||||
|
||||
FilePath ResourcePaths::getFallbackPath()
|
||||
FilePath ResourcePaths::getFallbackDirectoryPath()
|
||||
{
|
||||
return AppPath::getSharedDataPath().concatenate(L"data/fallback/");
|
||||
return AppPath::getSharedDataDirectoryPath().concatenate(L"data/fallback/");
|
||||
}
|
||||
|
||||
FilePath ResourcePaths::getFontsPath()
|
||||
FilePath ResourcePaths::getFontsDirectoryPath()
|
||||
{
|
||||
return AppPath::getSharedDataPath().concatenate(L"data/fonts/");
|
||||
return AppPath::getSharedDataDirectoryPath().concatenate(L"data/fonts/");
|
||||
}
|
||||
|
||||
FilePath ResourcePaths::getGuiPath()
|
||||
FilePath ResourcePaths::getGuiDirectoryPath()
|
||||
{
|
||||
return AppPath::getSharedDataPath().concatenate(L"data/gui/");
|
||||
return AppPath::getSharedDataDirectoryPath().concatenate(L"data/gui/");
|
||||
}
|
||||
|
||||
FilePath ResourcePaths::getLicensePath()
|
||||
FilePath ResourcePaths::getLicenseDirectoryPath()
|
||||
{
|
||||
return AppPath::getSharedDataPath().concatenate(L"data/license/");
|
||||
return AppPath::getSharedDataDirectoryPath().concatenate(L"data/license/");
|
||||
}
|
||||
|
||||
FilePath ResourcePaths::getJavaPath()
|
||||
FilePath ResourcePaths::getJavaDirectoryPath()
|
||||
{
|
||||
return AppPath::getSharedDataPath().concatenate(L"data/java/");
|
||||
return AppPath::getSharedDataDirectoryPath().concatenate(L"data/java/");
|
||||
}
|
||||
|
||||
FilePath ResourcePaths::getPythonDirectoryPath()
|
||||
{
|
||||
return AppPath::getSharedDataPath().concatenate(L"data/python/");
|
||||
return AppPath::getSharedDataDirectoryPath().concatenate(L"data/python/");
|
||||
}
|
||||
|
||||
FilePath ResourcePaths::getCxxCompilerHeaderPath()
|
||||
FilePath ResourcePaths::getCxxCompilerHeaderDirectoryPath()
|
||||
{
|
||||
return AppPath::getSharedDataPath().concatenate(L"data/cxx/include/").getCanonical();
|
||||
return AppPath::getSharedDataDirectoryPath().concatenate(L"data/cxx/include/").getCanonical();
|
||||
}
|
||||
|
||||
FilePath ResourcePaths::getPythonIndexerFilePath()
|
||||
|
||||
@@ -8,15 +8,15 @@
|
||||
class ResourcePaths
|
||||
{
|
||||
public:
|
||||
static FilePath getColorSchemesPath();
|
||||
static FilePath getSyntaxHighlightingRulesPath();
|
||||
static FilePath getFallbackPath();
|
||||
static FilePath getFontsPath();
|
||||
static FilePath getGuiPath();
|
||||
static FilePath getLicensePath();
|
||||
static FilePath getJavaPath();
|
||||
static FilePath getColorSchemesDirectoryPath();
|
||||
static FilePath getSyntaxHighlightingRulesDirectoryPath();
|
||||
static FilePath getFallbackDirectoryPath();
|
||||
static FilePath getFontsDirectoryPath();
|
||||
static FilePath getGuiDirectoryPath();
|
||||
static FilePath getLicenseDirectoryPath();
|
||||
static FilePath getJavaDirectoryPath();
|
||||
static FilePath getPythonDirectoryPath();
|
||||
static FilePath getCxxCompilerHeaderPath();
|
||||
static FilePath getCxxCompilerHeaderDirectoryPath();
|
||||
static FilePath getPythonIndexerFilePath();
|
||||
};
|
||||
|
||||
|
||||
@@ -1,28 +1,28 @@
|
||||
#include "UserPaths.h"
|
||||
|
||||
FilePath UserPaths::s_userDataPath;
|
||||
FilePath UserPaths::s_userDataDirectoryPath;
|
||||
|
||||
FilePath UserPaths::getUserDataPath()
|
||||
FilePath UserPaths::getUserDataDirectoryPath()
|
||||
{
|
||||
return s_userDataPath;
|
||||
return s_userDataDirectoryPath;
|
||||
}
|
||||
|
||||
void UserPaths::setUserDataPath(const FilePath& path)
|
||||
void UserPaths::setUserDataDirectoryPath(const FilePath& path)
|
||||
{
|
||||
s_userDataPath = path;
|
||||
s_userDataDirectoryPath = path;
|
||||
}
|
||||
|
||||
FilePath UserPaths::getAppSettingsPath()
|
||||
FilePath UserPaths::getAppSettingsFilePath()
|
||||
{
|
||||
return getUserDataPath().concatenate(L"ApplicationSettings.xml");
|
||||
return getUserDataDirectoryPath().concatenate(L"ApplicationSettings.xml");
|
||||
}
|
||||
|
||||
FilePath UserPaths::getWindowSettingsPath()
|
||||
FilePath UserPaths::getWindowSettingsFilePath()
|
||||
{
|
||||
return getUserDataPath().concatenate(L"window_settings.ini");
|
||||
return getUserDataDirectoryPath().concatenate(L"window_settings.ini");
|
||||
}
|
||||
|
||||
FilePath UserPaths::getLogPath()
|
||||
FilePath UserPaths::getLogDirectoryPath()
|
||||
{
|
||||
return getUserDataPath().concatenate(L"log/");
|
||||
return getUserDataDirectoryPath().concatenate(L"log/");
|
||||
}
|
||||
|
||||
@@ -8,15 +8,15 @@
|
||||
class UserPaths
|
||||
{
|
||||
public:
|
||||
static FilePath getUserDataPath();
|
||||
static void setUserDataPath(const FilePath& path);
|
||||
static FilePath getUserDataDirectoryPath();
|
||||
static void setUserDataDirectoryPath(const FilePath& path);
|
||||
|
||||
static FilePath getAppSettingsPath();
|
||||
static FilePath getWindowSettingsPath();
|
||||
static FilePath getLogPath();
|
||||
static FilePath getAppSettingsFilePath();
|
||||
static FilePath getWindowSettingsFilePath();
|
||||
static FilePath getLogDirectoryPath();
|
||||
|
||||
private:
|
||||
static FilePath s_userDataPath;
|
||||
static FilePath s_userDataDirectoryPath;
|
||||
};
|
||||
|
||||
#endif // USER_PATHS_H
|
||||
|
||||
@@ -553,7 +553,7 @@ GraphViewStyle::NodeStyle GraphViewStyle::getStyleOfBundleNode(bool isFocused)
|
||||
return getStyleForNodeType(
|
||||
NodeType::STYLE_BIG_NODE,
|
||||
"bundle",
|
||||
ResourcePaths::getGuiPath().concatenate(L"graph_view/images/bundle.png"),
|
||||
ResourcePaths::getGuiDirectoryPath().concatenate(L"graph_view/images/bundle.png"),
|
||||
true,
|
||||
false,
|
||||
isFocused,
|
||||
|
||||
@@ -183,21 +183,22 @@ FilePath NodeType::getIconPath() const
|
||||
if (isPackage())
|
||||
{
|
||||
// this icon cannot be changed
|
||||
return ResourcePaths::getGuiPath().concatenate(L"graph_view/images/namespace.png");
|
||||
return ResourcePaths::getGuiDirectoryPath().concatenate(L"graph_view/images/namespace.png");
|
||||
}
|
||||
|
||||
switch (m_kind)
|
||||
{
|
||||
case NODE_ANNOTATION:
|
||||
return ResourcePaths::getGuiPath().concatenate(L"graph_view/images/annotation.png");
|
||||
return ResourcePaths::getGuiDirectoryPath().concatenate(
|
||||
L"graph_view/images/annotation.png");
|
||||
case NODE_ENUM:
|
||||
return ResourcePaths::getGuiPath().concatenate(L"graph_view/images/enum.png");
|
||||
return ResourcePaths::getGuiDirectoryPath().concatenate(L"graph_view/images/enum.png");
|
||||
case NODE_TYPEDEF:
|
||||
return ResourcePaths::getGuiPath().concatenate(L"graph_view/images/typedef.png");
|
||||
return ResourcePaths::getGuiDirectoryPath().concatenate(L"graph_view/images/typedef.png");
|
||||
case NODE_MACRO:
|
||||
return ResourcePaths::getGuiPath().concatenate(L"graph_view/images/macro.png");
|
||||
return ResourcePaths::getGuiDirectoryPath().concatenate(L"graph_view/images/macro.png");
|
||||
case NODE_FILE:
|
||||
return ResourcePaths::getGuiPath().concatenate(L"graph_view/images/file.png");
|
||||
return ResourcePaths::getGuiDirectoryPath().concatenate(L"graph_view/images/file.png");
|
||||
default:
|
||||
return FilePath();
|
||||
}
|
||||
|
||||
@@ -178,7 +178,7 @@ void TaskBuildIndex::handleMessage(MessageIndexingInterrupted* message)
|
||||
|
||||
void TaskBuildIndex::runIndexerProcess(int processId, const std::wstring& logFilePath)
|
||||
{
|
||||
const FilePath indexerProcessPath = AppPath::getCxxIndexerPath();
|
||||
const FilePath indexerProcessPath = AppPath::getCxxIndexerFilePath();
|
||||
if (!indexerProcessPath.exists())
|
||||
{
|
||||
m_interrupted = true;
|
||||
@@ -191,8 +191,8 @@ void TaskBuildIndex::runIndexerProcess(int processId, const std::wstring& logFil
|
||||
std::vector<std::wstring> commandArguments;
|
||||
commandArguments.push_back(std::to_wstring(processId));
|
||||
commandArguments.push_back(utility::decodeFromUtf8(m_appUUID));
|
||||
commandArguments.push_back(AppPath::getSharedDataPath().getAbsolute().wstr());
|
||||
commandArguments.push_back(UserPaths::getUserDataPath().getAbsolute().wstr());
|
||||
commandArguments.push_back(AppPath::getSharedDataDirectoryPath().getAbsolute().wstr());
|
||||
commandArguments.push_back(UserPaths::getUserDataDirectoryPath().getAbsolute().wstr());
|
||||
|
||||
if (!logFilePath.empty())
|
||||
{
|
||||
|
||||
@@ -210,8 +210,9 @@ std::wstring ApplicationSettings::getColorSchemeName() const
|
||||
|
||||
FilePath ApplicationSettings::getColorSchemePath() const
|
||||
{
|
||||
FilePath defaultPath(ResourcePaths::getColorSchemesPath().concatenate(L"bright.xml"));
|
||||
FilePath path(ResourcePaths::getColorSchemesPath().concatenate(getColorSchemeName() + L".xml"));
|
||||
FilePath defaultPath(ResourcePaths::getColorSchemesDirectoryPath().concatenate(L"bright.xml"));
|
||||
FilePath path(
|
||||
ResourcePaths::getColorSchemesDirectoryPath().concatenate(getColorSchemeName() + L".xml"));
|
||||
|
||||
if (path != defaultPath && !path.exists())
|
||||
{
|
||||
@@ -340,7 +341,7 @@ void ApplicationSettings::setVerboseIndexerLoggingEnabled(bool value)
|
||||
FilePath ApplicationSettings::getLogDirectoryPath() const
|
||||
{
|
||||
return FilePath(getValue<std::wstring>(
|
||||
"application/log_directory_path", UserPaths::getLogPath().getAbsolute().wstr()));
|
||||
"application/log_directory_path", UserPaths::getLogDirectoryPath().getAbsolute().wstr()));
|
||||
}
|
||||
|
||||
void ApplicationSettings::setLogDirectoryPath(const FilePath& path)
|
||||
@@ -570,7 +571,7 @@ std::vector<FilePath> ApplicationSettings::getRecentProjects() const
|
||||
}
|
||||
else
|
||||
{
|
||||
recentProjects.push_back(UserPaths::getUserDataPath().concatenate(project));
|
||||
recentProjects.push_back(UserPaths::getUserDataDirectoryPath().concatenate(project));
|
||||
}
|
||||
}
|
||||
return recentProjects;
|
||||
|
||||
Reference in New Issue
Block a user