| OLD | NEW |
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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 #ifndef BASE_SCOPED_TEMP_DIR_H_ | 5 #ifndef BASE_FILES_SCOPED_TEMP_DIR_H_ |
| 6 #define BASE_SCOPED_TEMP_DIR_H_ | 6 #define BASE_FILES_SCOPED_TEMP_DIR_H_ |
| 7 | 7 |
| 8 // An object representing a temporary / scratch directory that should be cleaned | 8 // An object representing a temporary / scratch directory that should be cleaned |
| 9 // up (recursively) when this object goes out of scope. Note that since | 9 // up (recursively) when this object goes out of scope. Note that since |
| 10 // deletion occurs during the destructor, no further error handling is possible | 10 // deletion occurs during the destructor, no further error handling is possible |
| 11 // if the directory fails to be deleted. As a result, deletion is not | 11 // if the directory fails to be deleted. As a result, deletion is not |
| 12 // guaranteed by this class. | 12 // guaranteed by this class. |
| 13 // | 13 // |
| 14 // Multiple calls to the methods which establish a temporary directory | 14 // Multiple calls to the methods which establish a temporary directory |
| 15 // (CreateUniqueTempDir, CreateUniqueTempDirUnderPath, and Set) must have | 15 // (CreateUniqueTempDir, CreateUniqueTempDirUnderPath, and Set) must have |
| 16 // intervening calls to Delete or Take, or the calls will fail. | 16 // intervening calls to Delete or Take, or the calls will fail. |
| 17 | 17 |
| 18 #include "base/base_export.h" | 18 #include "base/base_export.h" |
| 19 #include "base/file_path.h" | 19 #include "base/file_path.h" |
| 20 | 20 |
| 21 namespace base { |
| 22 |
| 21 class BASE_EXPORT ScopedTempDir { | 23 class BASE_EXPORT ScopedTempDir { |
| 22 public: | 24 public: |
| 23 // No directory is owned/created initially. | 25 // No directory is owned/created initially. |
| 24 ScopedTempDir(); | 26 ScopedTempDir(); |
| 25 | 27 |
| 26 // Recursively delete path. | 28 // Recursively delete path. |
| 27 ~ScopedTempDir(); | 29 ~ScopedTempDir(); |
| 28 | 30 |
| 29 // Creates a unique directory in TempPath, and takes ownership of it. | 31 // Creates a unique directory in TempPath, and takes ownership of it. |
| 30 // See file_util::CreateNewTemporaryDirectory. | 32 // See file_util::CreateNewTemporaryDirectory. |
| (...skipping 17 matching lines...) Expand all Loading... |
| 48 | 50 |
| 49 // Returns true if path_ is non-empty and exists. | 51 // Returns true if path_ is non-empty and exists. |
| 50 bool IsValid() const; | 52 bool IsValid() const; |
| 51 | 53 |
| 52 private: | 54 private: |
| 53 FilePath path_; | 55 FilePath path_; |
| 54 | 56 |
| 55 DISALLOW_COPY_AND_ASSIGN(ScopedTempDir); | 57 DISALLOW_COPY_AND_ASSIGN(ScopedTempDir); |
| 56 }; | 58 }; |
| 57 | 59 |
| 58 #endif // BASE_SCOPED_TEMP_DIR_H_ | 60 } // namespace base |
| 61 |
| 62 #endif // BASE_FILES_SCOPED_TEMP_DIR_H_ |
| OLD | NEW |