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

Unified Diff: base/file_util_posix.cc

Issue 10690047: Fix a bug in file_util::Delete() where symlinks are not handled right (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: . Created 8 years, 6 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
« no previous file with comments | « no previous file | base/file_util_unittest.cc » ('j') | base/file_util_unittest.cc » ('J')
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: base/file_util_posix.cc
diff --git a/base/file_util_posix.cc b/base/file_util_posix.cc
index c9a0d9bb474c2d8e6f15321b67c72999f1153b66..2f771dbbaf4ff6c957258dd924a5834fcbbcd891 100644
--- a/base/file_util_posix.cc
+++ b/base/file_util_posix.cc
@@ -207,8 +207,8 @@ bool Delete(const FilePath& path, bool recursive) {
base::ThreadRestrictions::AssertIOAllowed();
const char* path_str = path.value().c_str();
stat_wrapper_t file_info;
- int test = CallStat(path_str, &file_info);
- if (test != 0) {
+ int test_link = CallLstat(path_str, &file_info);
satorux1 2012/06/29 18:25:20 test_link -> test. lstat() checks regular files to
yoshiki 2012/06/29 19:12:27 Done.
+ if (test_link != 0) {
// The Windows version defines this condition as success.
bool ret = (errno == ENOENT || errno == ENOTDIR);
return ret;
@@ -578,10 +578,10 @@ bool CreateDirectory(const FilePath& full_path) {
// TODO(rkc): Refactor GetFileInfo and FileEnumerator to handle symlinks
// correctly. http://code.google.com/p/chromium-os/issues/detail?id=15948
bool IsLink(const FilePath& file_path) {
- struct stat st;
+ stat_wrapper_t st;
// If we can't lstat the file, it's safe to assume that the file won't at
// least be a 'followable' link.
- if (lstat(file_path.value().c_str(), &st) != 0)
+ if (CallLstat(file_path.value().c_str(), &st) != 0)
return false;
if (S_ISLNK(st.st_mode))
« no previous file with comments | « no previous file | base/file_util_unittest.cc » ('j') | base/file_util_unittest.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698