Fix fileutils.cc for tests running under Win memory tools.

On Windows, when tests are run under memory tools like
DrMemory and TSan, slashes occur in the path as directory
separators. This makes the fileutils.cc fail to figure out
the project root, making paths to resource files invalid.

By replacing slashes in the path with backslashes for Windows
this can be fixed.

BUG=2318
TEST=running the same command as the bot locally, succeeding after this patch is applied.
R=phoglund@webrtc.org

Review URL: https://webrtc-codereview.appspot.com/2137004

git-svn-id: http://webrtc.googlecode.com/svn/trunk/webrtc@4640 4adac7df-926f-26a2-2b94-8c16560cd09d
diff --git a/test/testsupport/fileutils.cc b/test/testsupport/fileutils.cc
index d19d50f..c89f9bd 100644
--- a/test/testsupport/fileutils.cc
+++ b/test/testsupport/fileutils.cc
@@ -12,6 +12,7 @@
 
 #ifdef WIN32
 #include <direct.h>
+#include <algorithm>
 #define GET_CURRENT_DIR _getcwd
 #else
 #include <unistd.h>
@@ -67,6 +68,13 @@
   if (path.find(working_dir) != std::string::npos) {
     temp_path = path.substr(working_dir.length() + 1);
   }
+  // On Windows, when tests are run under memory tools like DrMemory and TSan,
+  // slashes occur in the path as directory separators. Make sure we replace
+  // such cases with backslashes in order for the paths to be correct.
+#ifdef WIN32
+  std::replace(temp_path.begin(), temp_path.end(), '/', '\\');
+#endif
+
   // Trim away the executable name; only store the relative dir path.
   temp_path = temp_path.substr(0, temp_path.find_last_of(kPathDelimiter));
   strncpy(relative_dir_path, temp_path.c_str(), FILENAME_MAX);