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: Comments addressed Created April 30, 2013, 8:09 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
@@ -85,45 +85,19 @@
std::string DefaultFileSystem::Resolve(const std::string& path) const
{
-#ifdef WIN32
- // Resolve to LocalLow folder
+ return basePath + "\\" + path;
Felix Dahlke 2013/04/30 09:14:52 \\ won't work on UNIX, but I think / should work e
Wladimir Palant 2013/04/30 09:29:50 1) This path separator is Windows-specific. Please
+}
- OSVERSIONINFOEX osvi;
- ZeroMemory(&osvi, sizeof(OSVERSIONINFOEX));
- osvi.dwOSVersionInfoSize = sizeof(OSVERSIONINFOEX);
- BOOL res = GetVersionEx((OSVERSIONINFO*) &osvi);
+void DefaultFileSystem::SetBasePath(const std::string& path)
+{
- if(res == 0 ) return std::string(path);
-
- std::wstring resolvedW = L"";
- wchar_t resolvedPath[MAX_PATH];
- HRESULT hr;
- if (osvi.dwMajorVersion >= 6)
+ if (path.rfind('\\') == (path.length() - 1))
Felix Dahlke 2013/04/30 09:14:52 How about if (*path.rbegin() == '\\')? This also
Wladimir Palant 2013/04/30 09:29:50 Please search for PATH_SEPARATOR here as well, not
{
- hr = SHGetFolderPath(NULL, CSIDL_LOCAL_APPDATA, 0, 0, resolvedPath);
+ basePath = path.substr(0, path.length() - 1);
Felix Dahlke 2013/04/30 09:14:52 Never used this, but basePath.pop_back(); seems to
}
else
{
- hr = SHGetFolderPath(NULL, CSIDL_APPDATA, 0, 0, resolvedPath);
+ basePath = path;
}
- if (FAILED(hr))
- return std::string(path);
- resolvedW.assign(resolvedPath);
-
- // TODO: Better conversion here
- std::string resolved(resolvedW.begin(), resolvedW.end());
- if (osvi.dwMajorVersion >= 6)
- {
- resolved.append("Low\\AdblockPlus\\");
- }
- else
- {
- resolved.append("\\AdblockPlus\\");
- }
- resolved.append(path);
- return resolved;
-#else
- return std::string(path);
-#endif
}

Powered by Google App Engine
This is Rietveld