diff options
Diffstat (limited to 'base/scoped_temp_dir.cc')
-rw-r--r-- | base/scoped_temp_dir.cc | 18 |
1 files changed, 14 insertions, 4 deletions
diff --git a/base/scoped_temp_dir.cc b/base/scoped_temp_dir.cc index 5cd13b4..000ed0a 100644 --- a/base/scoped_temp_dir.cc +++ b/base/scoped_temp_dir.cc @@ -11,7 +11,8 @@ ScopedTempDir::ScopedTempDir() { } ScopedTempDir::~ScopedTempDir() { - Delete(); + if (!path_.empty() && !Delete()) + LOG(WARNING) << "Could not delete temp dir in dtor."; } bool ScopedTempDir::CreateUniqueTempDir() { @@ -57,10 +58,19 @@ bool ScopedTempDir::Set(const FilePath& path) { return true; } -void ScopedTempDir::Delete() { - if (!path_.empty() && !file_util::Delete(path_, true)) +bool ScopedTempDir::Delete() { + if (path_.empty()) + return false; + + bool ret = file_util::Delete(path_, true); + if (ret) { + // We only clear the path if deleted the directory. + path_.clear(); + } else { LOG(ERROR) << "ScopedTempDir unable to delete " << path_.value(); - path_.clear(); + } + + return ret; } FilePath ScopedTempDir::Take() { |