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

Unified Diff: src/engine/Utils.cpp

Issue 10790071: Send debug output to a file (Closed)
Patch Set: Created May 31, 2013, 9:54 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/engine/Utils.cpp
===================================================================
new file mode 100644
--- /dev/null
+++ b/src/engine/Utils.cpp
@@ -0,0 +1,40 @@
+#include "stdafx.h"
+#include "Utils.h"
+
+namespace
+{
+ static std::wstring appDataPath;
+
+ bool IsWindowsVistaOrLater()
+ {
+ OSVERSIONINFOEX osvi;
+ ZeroMemory(&osvi, sizeof(OSVERSIONINFOEX));
+ osvi.dwOSVersionInfoSize = sizeof(OSVERSIONINFOEX);
+ GetVersionEx(reinterpret_cast<LPOSVERSIONINFO>(&osvi));
+ return osvi.dwMajorVersion >= 6;
+ }
+}
+
+std::wstring GetAppDataPath()
+{
+ if (appDataPath.empty())
+ {
+ if (IsWindowsVistaOrLater())
+ {
+ WCHAR* pathBuffer;
+ if (FAILED(SHGetKnownFolderPath(FOLDERID_LocalAppDataLow, 0, 0, &pathBuffer)))
+ throw std::runtime_error("Unable to find app data directory");
+ appDataPath.assign(pathBuffer);
+ CoTaskMemFree(pathBuffer);
+ }
+ else
+ {
+ std::auto_ptr<wchar_t> pathBuffer(new wchar_t[MAX_PATH]);
+ if (!SHGetSpecialFolderPath(0, pathBuffer.get(), CSIDL_LOCAL_APPDATA, true))
+ throw std::runtime_error("Unable to find app data directory");
+ appDataPath.assign(pathBuffer.get());
+ }
+ appDataPath += L"\\AdblockPlus";
+ }
+ return appDataPath;
+}
« src/engine/Debug.cpp ('K') | « src/engine/Utils.h ('k') | src/engine/main.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld