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: Addressing comments Created May 5, 2013, 10:49 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
« no previous file with comments | « include/AdblockPlus/FileSystem.h ('k') | test/BaseJsTest.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/DefaultFileSystem.cpp
===================================================================
--- a/src/DefaultFileSystem.cpp
+++ b/src/DefaultFileSystem.cpp
@@ -12,6 +12,7 @@
#ifndef S_ISDIR
#define S_ISDIR(mode) (((mode) & S_IFMT) == S_IFDIR)
#include <Shlobj.h>
+#include <Shlwapi.h>
#endif
#ifndef S_ISREG
@@ -91,19 +92,30 @@
std::string DefaultFileSystem::Resolve(const std::string& path) const
{
- return basePath + "\\" + path;
+ if (basePath == "")
+ {
+ return path;
+ }
+ else
+ {
+ if (PathIsRelative(Utils::ToUTF16String(path, path.length()).c_str()))
Wladimir Palant 2013/05/06 06:18:30 This is Windows-specific and won't compile on othe
Wladimir Palant 2013/05/06 06:19:51 Oops, exactly the other way round of course: i
+ {
+ return basePath + PATH_SEPARATOR + path;
+ }
+ else
+ {
+ return path;
+ }
+ }
}
void DefaultFileSystem::SetBasePath(const std::string& path)
{
+ basePath = path;
- if (path.rfind('\\') == (path.length() - 1))
+ if ((*basePath.rbegin() == PATH_SEPARATOR))
Wladimir Palant 2013/05/06 06:18:30 Nit: You seem to have an extra pair parentheses he
{
- basePath = path.substr(0, path.length() - 1);
- }
- else
- {
- basePath = path;
+ basePath.pop_back();
}
}
« no previous file with comments | « include/AdblockPlus/FileSystem.h ('k') | test/BaseJsTest.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld