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

Side by Side Diff: base/scoped_temp_dir.h

Issue 19411: Add ScopedTempDir - a class that manages the lifetime of a temporary director... (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: '' Created 11 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 | Annotate | Revision Log
« no previous file with comments | « base/build/base_unittests.vcproj ('k') | base/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')
Property Changes:
Added: svn:eol-style
+ LF
OLDNEW
(Empty)
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
3 // found in the LICENSE file.
4
5 #ifndef BASE_SCOPED_TEMP_DIR_H_
6 #define BASE_SCOPED_TEMP_DIR_H_
7
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
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
12 // guaranteed by this class.
13
14 #include "base/file_path.h"
15
16 class ScopedTempDir {
17 public:
18 // No directory is owned/created initially.
19 ScopedTempDir();
20
21 // Recursively delete path_
22 ~ScopedTempDir();
23
24 // Creates a unique directory in TempPath, and takes ownership of it.
25 // See file_util::CreateNewTemporaryDirectory.
26 bool CreateUniqueTempDir();
27
28 // Takes ownership of directory at |path|, creating it if necessary.
29 // Don't call multiple times unless Take() has been called first.
30 bool Set(const FilePath& path);
31
32 // Caller takes ownership of the temporary directory so it won't be destroyed
33 // when this object goes out of scope.
34 FilePath Take();
35
36 const FilePath& path() const { return path_; }
37
38 // Returns true if path_ is non-empty and exists.
39 bool IsValid() const;
40
41 private:
42 FilePath path_;
43
44 DISALLOW_COPY_AND_ASSIGN(ScopedTempDir);
45 };
46
47 #endif // BASE_SCOPED_TEMP_DIR_H_
OLDNEW
« no previous file with comments | « base/build/base_unittests.vcproj ('k') | base/scoped_temp_dir.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698