Rietveld Code Review Tool
Help | Bug tracker | Discussion group | Source code

Unified Diff: src/plugin/PluginUtil.cpp

Issue 10897028: Create a shared dictionary class for plugin and engine (Closed)
Patch Set: Created June 7, 2013, 12:42 p.m.
Use n/p to move between diff chunks; N/P to move between comments.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: src/plugin/PluginUtil.cpp
===================================================================
--- a/src/plugin/PluginUtil.cpp
+++ b/src/plugin/PluginUtil.cpp
@@ -1,13 +1,14 @@
#include "PluginStdAfx.h"
#include <algorithm>
#include <stdexcept>
#include <vector>
+#include "../shared/Utils.h"
#include "PluginUtil.h"
#include "PluginSettings.h"
BString::BString(const std::wstring& value)
: value(::SysAllocString(value.c_str()))
{
}
@@ -16,49 +17,19 @@ BString::~BString()
::SysFreeString(value);
}
BString::operator BSTR()
{
return value;
}
-std::wstring DllDir()
-{
- std::vector<WCHAR> path(MAX_PATH);
- DWORD length = GetModuleFileNameW((HINSTANCE)&__ImageBase, &path[0], path.size());
-
- while (length == path.size())
- {
- // Buffer too small, double buffer size
- path.resize(path.size() * 2);
- length = GetModuleFileNameW((HINSTANCE)&__ImageBase, &path[0], path.size());
- }
-
- try
- {
- if (length == 0)
- throw std::runtime_error("Failed determining module path");
-
- std::vector<WCHAR>::reverse_iterator it = std::find(path.rbegin(), path.rend(), L'\\');
- if (it == path.rend())
- throw std::runtime_error("Unexpected plugin path, no backslash found");
-
- return std::wstring(path.begin(), it.base());
- }
- catch (const std::exception& e)
- {
- DEBUG_GENERAL(e.what());
- return std::wstring();
- }
-}
-
std::wstring UserSettingsFileUrl()
{
- return FileUrl(DllDir() + L"html\\templates\\index.html");
+ return FileUrl(GetDllDir() + L"html\\templates\\index.html");
}
std::wstring FileUrl(const std::wstring& path)
{
std::wstring url = path;
std::replace(url.begin(), url.end(), L'\\', L'/');
return L"file:///" + url;
}

Powered by Google App Engine
This is Rietveld