summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorphajdan.jr@chromium.org <phajdan.jr@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-01-13 18:57:46 +0000
committerphajdan.jr@chromium.org <phajdan.jr@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-01-13 18:57:46 +0000
commitca020961d05b2c38dcc94c0e10a4ab41dbeac900 (patch)
treeaeab55264e5064fd3dea7ea029965520ec42d0ba
parente33920797943e123825f343b07d2d40a71067af0 (diff)
downloadchromium_src-ca020961d05b2c38dcc94c0e10a4ab41dbeac900.zip
chromium_src-ca020961d05b2c38dcc94c0e10a4ab41dbeac900.tar.gz
chromium_src-ca020961d05b2c38dcc94c0e10a4ab41dbeac900.tar.bz2
Fix TODOs in base/ :
- switch to FilePath inside CopyDirectory - be less racy in ProcessUtilTest.KillSlowChild Review URL: http://codereview.chromium.org/17013 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@7948 0039d316-1c4b-4281-b951-d872f2087c98
-rw-r--r--base/file_util_posix.cc15
-rw-r--r--base/process_util_unittest.cc3
2 files changed, 10 insertions, 8 deletions
diff --git a/base/file_util_posix.cc b/base/file_util_posix.cc
index 3bab4d1..9ab29eb 100644
--- a/base/file_util_posix.cc
+++ b/base/file_util_posix.cc
@@ -139,8 +139,13 @@ bool CopyDirectory(const FilePath& from_path,
while (!error && (ent = fts_read(fts)) != NULL) {
// ent->fts_path is the source path, including from_path, so paste
// the suffix after from_path onto to_path to create the target_path.
- const std::string target_path =
- to_path.value() + &ent->fts_path[from_path.value().size()];
+ std::string suffix(&ent->fts_path[from_path.value().size()]);
+ // Strip the leading '/' (if any).
+ if (!suffix.empty()) {
+ DCHECK(suffix[0] == '/');
+ suffix.erase(0, 1);
+ }
+ const FilePath target_path = to_path.Append(suffix);
switch (ent->fts_info) {
case FTS_D: // Preorder directory.
// If we encounter a subdirectory in a non-recursive copy, prune it
@@ -152,17 +157,15 @@ bool CopyDirectory(const FilePath& from_path,
}
// Try creating the target dir, continuing on it if it exists already.
- if (mkdir(target_path.c_str(), 0777) != 0) {
+ if (mkdir(target_path.value().c_str(), 0777) != 0) {
if (errno != EEXIST)
error = errno;
}
break;
case FTS_F: // Regular file.
case FTS_NSOK: // File, no stat info requested.
- // TODO(port): use a native file path rather than all these
- // conversions.
errno = 0;
- if (!CopyFile(UTF8ToWide(ent->fts_path), UTF8ToWide(target_path)))
+ if (!CopyFile(FilePath(ent->fts_path), target_path))
error = errno ? errno : EINVAL;
break;
case FTS_DP: // Postorder directory.
diff --git a/base/process_util_unittest.cc b/base/process_util_unittest.cc
index 92c623b..5723a83 100644
--- a/base/process_util_unittest.cc
+++ b/base/process_util_unittest.cc
@@ -67,8 +67,7 @@ TEST_F(ProcessUtilTest, KillSlowChild) {
EXPECT_EQ(oldcount+1, GetProcessCount(L"base_unittests" EXE_SUFFIX, 0));
FILE *fp = fopen("SlowChildProcess.die", "w");
fclose(fp);
- // TODO(port): do something less racy here
- PlatformThread::Sleep(1000);
+ EXPECT_TRUE(base::WaitForSingleProcess(handle, 5000));
EXPECT_EQ(oldcount, GetProcessCount(L"base_unittests" EXE_SUFFIX, 0));
}
#endif