Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1688)

Unified Diff: base/file_util_posix.cc

Issue 13196006: Move path functions from file_util to FilePath object. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: git try Created 7 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: base/file_util_posix.cc
diff --git a/base/file_util_posix.cc b/base/file_util_posix.cc
index 8bf164ace5c4a175907d416672e0507362808e6c..8b368127410e091eb392cf440f2bd9c50a417acd 100644
--- a/base/file_util_posix.cc
+++ b/base/file_util_posix.cc
@@ -59,6 +59,19 @@
#endif
using base::FilePath;
+using base::MakeAbsoluteFilePath;
+
+namespace base {
+
+FilePath MakeAbsoluteFilePath(const FilePath& input) {
+ base::ThreadRestrictions::AssertIOAllowed();
+ char full_path[PATH_MAX];
+ if (realpath(input.value().c_str(), full_path) == NULL)
+ return FilePath();
+ return FilePath(full_path);
+}
+
+} // namespace base
namespace file_util {
@@ -150,15 +163,6 @@ static std::string TempFileName() {
#endif
}
-bool AbsolutePath(FilePath* path) {
- base::ThreadRestrictions::AssertIOAllowed(); // For realpath().
- char full_path[PATH_MAX];
- if (realpath(path->value().c_str(), full_path) == NULL)
- return false;
- *path = FilePath(full_path);
- return true;
-}
-
// TODO(erikkay): The Windows version of this accepts paths like "foo/bar/*"
// which works both with and without the recursive flag. I'm not sure we need
// that functionality. If not, remove from file_util_win.cc, otherwise add it
@@ -253,15 +257,16 @@ bool CopyDirectory(const FilePath& from_path,
// This function does not properly handle destinations within the source
FilePath real_to_path = to_path;
if (PathExists(real_to_path)) {
- if (!AbsolutePath(&real_to_path))
+ real_to_path = MakeAbsoluteFilePath(real_to_path);
+ if (real_to_path.empty())
return false;
} else {
- real_to_path = real_to_path.DirName();
- if (!AbsolutePath(&real_to_path))
+ real_to_path = MakeAbsoluteFilePath(real_to_path.DirName());
+ if (real_to_path.empty())
return false;
}
- FilePath real_from_path = from_path;
- if (!AbsolutePath(&real_from_path))
+ FilePath real_from_path = MakeAbsoluteFilePath(from_path);
+ if (real_from_path.empty())
return false;
if (real_to_path.value().size() >= real_from_path.value().size() &&
real_to_path.value().compare(0, real_from_path.value().size(),

Powered by Google App Engine
This is Rietveld 408576698