Gazebo Common

API Reference

6.0.1
TempDirectory.hh
Go to the documentation of this file.
1/*
2 * Copyright 2021 Open Source Robotics Foundation
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 *
16 */
17
18#ifndef GZ_COMMON_TEMPDIRECTORY_HH_
19#define GZ_COMMON_TEMPDIRECTORY_HH_
20
21#include <string>
22
23#include <gz/common/Export.hh>
25
26#include <gz/utils/ImplPtr.hh>
27
28namespace gz
29{
30 namespace common
31 {
37 std::string GZ_COMMON_VISIBLE tempDirectoryPath();
38
51 const std::string &_baseName,
52 const std::string &_parentPath,
53 const FilesystemWarningOp _warningOp = FSWO_LOG_WARNINGS);
54
61 class GZ_COMMON_VISIBLE TempDirectory
62 {
73 public: TempDirectory(const std::string &_prefix = "temp_dir",
74 const std::string &_subDir = "gz",
75 bool _cleanup = true);
76
88 public: explicit TempDirectory(const std::string &_root,
89 const std::string &_prefix = "temp_dir",
90 const std::string &_subDir = "gz",
91 bool _cleanup = true);
92
95 public: ~TempDirectory();
96
100 public: bool Valid() const;
101
108 public: void DoCleanup(bool _doCleanup);
109
112 public: bool DoCleanup() const;
113
116 public: std::string Path() const;
117
119 GZ_UTILS_UNIQUE_IMPL_PTR(dataPtr)
120 };
121 } // namespace common
122} // namespace gz
123#endif // GZ_COMMON_TEMPDIRECTORY_HH_