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

Side by Side Diff: util/test/scoped_temp_dir.h

Issue 834693002: Create ScopedTempDir, implement it on POSIX, and use it where appropriate. (Closed) Base URL: https://chromium.googlesource.com/crashpad/crashpad@master
Patch Set: For landing Created 5 years, 11 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 unified diff | Download patch
« no previous file with comments | « util/mac/xattr_test.cc ('k') | util/test/scoped_temp_dir.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
1 // Copyright 2015 The Crashpad Authors. All rights reserved.
2 //
3 // Licensed under the Apache License, Version 2.0 (the "License");
4 // you may not use this file except in compliance with the License.
5 // You may obtain a copy of the License at
6 //
7 // http://www.apache.org/licenses/LICENSE-2.0
8 //
9 // Unless required by applicable law or agreed to in writing, software
10 // distributed under the License is distributed on an "AS IS" BASIS,
11 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 // See the License for the specific language governing permissions and
13 // limitations under the License.
14
15 #ifndef CRASHPAD_UTIL_TEST_SCOPED_TEMP_DIR_
16 #define CRASHPAD_UTIL_TEST_SCOPED_TEMP_DIR_
17
18 #include "base/basictypes.h"
19 #include "base/files/file_path.h"
20
21 namespace crashpad {
22 namespace test {
23
24 //! \brief A RAII object that creates a temporary directory for testing.
25 //!
26 //! Upon construction, a temporary directory will be created. Failure to create
27 //! the directory is fatal. On destruction, the directory and all its contents
28 //! will be removed.
29 class ScopedTempDir {
30 public:
31 ScopedTempDir();
32 ~ScopedTempDir();
33
34 //! \brief Returns the path of the temporary directory.
35 //!
36 //! \return The temporary directory path.
37 const base::FilePath& path() const { return path_; }
38
39 private:
40 //! \brief Creates the temporary directory and asserts success of the
41 //! operation.
42 static base::FilePath CreateTemporaryDirectory();
43
44 //! \brief Removes all files and subdirectories at the given \a path,
45 //! including the \a path itself.
46 //!
47 //! Failures are recorded by gtest expectations.
48 //!
49 //! \param[in] path The path to delete, along with its contents. This must
50 //! reference a directory.
51 static void RecursivelyDeleteTemporaryDirectory(const base::FilePath& path);
52
53 const base::FilePath path_;
54
55 DISALLOW_COPY_AND_ASSIGN(ScopedTempDir);
56 };
57
58 } // namespace test
59 } // namespace crashpad
60
61 #endif // CRASHPAD_UTIL_TEST_SCOPED_TEMP_DIR_
OLDNEW
« no previous file with comments | « util/mac/xattr_test.cc ('k') | util/test/scoped_temp_dir.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698