diff options
author | phajdan.jr@chromium.org <phajdan.jr@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-01-13 18:57:46 +0000 |
---|---|---|
committer | phajdan.jr@chromium.org <phajdan.jr@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-01-13 18:57:46 +0000 |
commit | ca020961d05b2c38dcc94c0e10a4ab41dbeac900 (patch) | |
tree | aeab55264e5064fd3dea7ea029965520ec42d0ba /base/file_util_posix.cc | |
parent | e33920797943e123825f343b07d2d40a71067af0 (diff) | |
download | chromium_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
Diffstat (limited to 'base/file_util_posix.cc')
-rw-r--r-- | base/file_util_posix.cc | 15 |
1 files changed, 9 insertions, 6 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. |