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

Unified Diff: src/DefaultFileSystem.cpp

Issue 10369004: File system path resolving (Closed)
Patch Set: Created April 24, 2013, 2:10 a.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/DefaultFileSystem.cpp
===================================================================
--- a/src/DefaultFileSystem.cpp
+++ b/src/DefaultFileSystem.cpp
@@ -11,6 +11,7 @@
#ifdef _WIN32
#ifndef S_ISDIR
#define S_ISDIR(mode) (((mode) & S_IFMT) == S_IFDIR)
+#include <Shlobj.h>
#endif
#ifndef S_ISREG
@@ -81,3 +82,25 @@
result.lastModified = static_cast<int64_t>(nativeStat.st_mtime) * 1000;
return result;
}
+
+std::string DefaultFileSystem::Resolve(const std::string& path) const
+{
+#ifdef WIN32
+ // Resolve to LocalLow folder
+ wchar_t* resolvedPath;
+ HRESULT hr = SHGetKnownFolderPath(FOLDERID_LocalAppDataLow, 0, NULL, &resolvedPath);
+ if (FAILED(hr))
+ return std::string(path);
Wladimir Palant 2013/04/24 09:17:35 Why not just return path; here?
+ std::wstring resolvedW(resolvedPath);
+ CoTaskMemFree(resolvedPath);
+
+ // TODO: Better conversion here
+ std::string resolved(resolvedW.begin(), resolvedW.end());
Wladimir Palant 2013/04/24 09:17:35 Please use Utils::ToUTF8String() here (and we are
+ resolved.append("\\AdblockPlus\\");
+ resolved.append(path);
+ return resolved;
+#else
+ return std::string(path);
Wladimir Palant 2013/04/24 09:17:35 Why not just return path; here?
+#endif
+}
+
« no previous file with comments | « lib/io.js ('k') | src/FileSystemJsObject.cpp » ('j') | src/FileSystemJsObject.cpp » ('J')

Powered by Google App Engine
This is Rietveld