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

Side by Side Diff: base/scoped_temp_dir.cc

Issue 5340004: Make ScopedTempDir::Delete return a bool so that its functionality can be te... (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: Created 10 years 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 unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2009 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2009 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "base/scoped_temp_dir.h" 5 #include "base/scoped_temp_dir.h"
6 6
7 #include "base/file_util.h" 7 #include "base/file_util.h"
8 #include "base/logging.h" 8 #include "base/logging.h"
9 9
10 ScopedTempDir::ScopedTempDir() { 10 ScopedTempDir::ScopedTempDir() {
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after
50 return false; 50 return false;
51 51
52 if (!file_util::DirectoryExists(path) && 52 if (!file_util::DirectoryExists(path) &&
53 !file_util::CreateDirectory(path)) 53 !file_util::CreateDirectory(path))
54 return false; 54 return false;
55 55
56 path_ = path; 56 path_ = path;
57 return true; 57 return true;
58 } 58 }
59 59
60 void ScopedTempDir::Delete() { 60 bool ScopedTempDir::Delete() {
61 if (!path_.empty() && !file_util::Delete(path_, true)) 61 bool ret = false;
62 LOG(ERROR) << "ScopedTempDir unable to delete " << path_.value(); 62 if (!path_.empty()) {
Paweł Hajdan Jr. 2010/11/26 21:01:20 nit: Rather: if (path.empty()) return false;
tommi (sloooow) - chröme 2010/11/26 21:04:44 Done.
63 path_.clear(); 63 ret = file_util::Delete(path_, true);
64 if (!ret) {
Paweł Hajdan Jr. 2010/11/26 21:01:20 nit: Put success case first to avoid double-negati
tommi (sloooow) - chröme 2010/11/26 21:04:44 Done.
65 // Note that we don't clear the path if we can't delete the directory.
66 LOG(ERROR) << "ScopedTempDir unable to delete " << path_.value();
67 } else {
68 path_.clear();
69 }
70 }
71 return ret;
64 } 72 }
65 73
66 FilePath ScopedTempDir::Take() { 74 FilePath ScopedTempDir::Take() {
67 FilePath ret = path_; 75 FilePath ret = path_;
68 path_ = FilePath(); 76 path_ = FilePath();
69 return ret; 77 return ret;
70 } 78 }
71 79
72 bool ScopedTempDir::IsValid() const { 80 bool ScopedTempDir::IsValid() const {
73 return !path_.empty() && file_util::DirectoryExists(path_); 81 return !path_.empty() && file_util::DirectoryExists(path_);
74 } 82 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698