summaryrefslogtreecommitdiff
path: root/plugins/CurrencyRates/src/CreateFilePath.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'plugins/CurrencyRates/src/CreateFilePath.cpp')
-rw-r--r--plugins/CurrencyRates/src/CreateFilePath.cpp33
1 files changed, 33 insertions, 0 deletions
diff --git a/plugins/CurrencyRates/src/CreateFilePath.cpp b/plugins/CurrencyRates/src/CreateFilePath.cpp
new file mode 100644
index 0000000000..449d8b7ae7
--- /dev/null
+++ b/plugins/CurrencyRates/src/CreateFilePath.cpp
@@ -0,0 +1,33 @@
+#include "StdAfx.h"
+
+static wchar_t InvalidSymbols[] = { '\\', '/', ':', '*', '?', '"', '<', '>', '|' };
+
+static wchar_t replace_invalid_symbol(wchar_t chr)
+{
+ for (int i = 0; i < _countof(InvalidSymbols); ++i)
+ if (chr == InvalidSymbols[i])
+ return '_';
+
+ return chr;
+}
+
+void prepare_name(tstring& rsName)
+{
+ std::transform(rsName.begin(), rsName.end(), rsName.begin(), boost::bind(replace_invalid_symbol, _1));
+}
+
+tstring CreateFilePath(const tstring& rsName)
+{
+ wchar_t szPath[_MAX_PATH];
+ ::GetModuleFileName(g_plugin.getInst(), szPath, _MAX_PATH);
+
+ wchar_t* p = wcsrchr(szPath, '\\');
+ if (p)
+ *p = 0;
+
+ tstring s(rsName);
+ prepare_name(s);
+ tostringstream o;
+ o << szPath << L"\\Quotes\\" << s;
+ return o.str();
+} \ No newline at end of file