ipc/chromium/src/base/scoped_temp_dir.h

Wed, 31 Dec 2014 06:09:35 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Wed, 31 Dec 2014 06:09:35 +0100
changeset 0
6474c204b198
permissions
-rw-r--r--

Cloned upstream origin tor-browser at tor-browser-31.3.0esr-4.5-1-build1
revision ID fc1c9ff7c1b2defdbc039f12214767608f46423f for hacking purpose.

michael@0 1 // Copyright (c) 2009 The Chromium Authors. All rights reserved.
michael@0 2 // Use of this source code is governed by a BSD-style license that can be
michael@0 3 // found in the LICENSE file.
michael@0 4
michael@0 5 #ifndef BASE_SCOPED_TEMP_DIR_H_
michael@0 6 #define BASE_SCOPED_TEMP_DIR_H_
michael@0 7
michael@0 8 // An object representing a temporary / scratch directory that should be cleaned
michael@0 9 // up (recursively) when this object goes out of scope. Note that since
michael@0 10 // deletion occurs during the destructor, no further error handling is possible
michael@0 11 // if the directory fails to be deleted. As a result, deletion is not
michael@0 12 // guaranteed by this class.
michael@0 13
michael@0 14 #include "base/file_path.h"
michael@0 15
michael@0 16 class ScopedTempDir {
michael@0 17 public:
michael@0 18 // No directory is owned/created initially.
michael@0 19 ScopedTempDir();
michael@0 20
michael@0 21 // Recursively delete path_
michael@0 22 ~ScopedTempDir();
michael@0 23
michael@0 24 // Creates a unique directory in TempPath, and takes ownership of it.
michael@0 25 // See file_util::CreateNewTemporaryDirectory.
michael@0 26 bool CreateUniqueTempDir();
michael@0 27
michael@0 28 // Takes ownership of directory at |path|, creating it if necessary.
michael@0 29 // Don't call multiple times unless Take() has been called first.
michael@0 30 bool Set(const FilePath& path);
michael@0 31
michael@0 32 // Caller takes ownership of the temporary directory so it won't be destroyed
michael@0 33 // when this object goes out of scope.
michael@0 34 FilePath Take();
michael@0 35
michael@0 36 const FilePath& path() const { return path_; }
michael@0 37
michael@0 38 // Returns true if path_ is non-empty and exists.
michael@0 39 bool IsValid() const;
michael@0 40
michael@0 41 private:
michael@0 42 FilePath path_;
michael@0 43
michael@0 44 DISALLOW_COPY_AND_ASSIGN(ScopedTempDir);
michael@0 45 };
michael@0 46
michael@0 47 #endif // BASE_SCOPED_TEMP_DIR_H_

mercurial