Ignition Common

API Reference

4.4.0
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 IGNITION_COMMON_TEMPDIRECTORY_HH_
19 #define IGNITION_COMMON_TEMPDIRECTORY_HH_
20 
21 #include <memory>
22 #include <string>
23 
24 #include <ignition/common/Export.hh>
26 
27 namespace ignition
28 {
29  namespace common
30  {
31  class TempDirectoryPrivate;
32 
38  std::string IGNITION_COMMON_VISIBLE tempDirectoryPath();
39 
51  std::string IGNITION_COMMON_VISIBLE createTempDirectory(
52  const std::string &_baseName,
53  const std::string &_parentPath,
54  const FilesystemWarningOp _warningOp = FSWO_LOG_WARNINGS);
55 
62  class IGNITION_COMMON_VISIBLE TempDirectory
63  {
74  public: TempDirectory(const std::string &_prefix = "temp_dir",
75  const std::string &_subDir = "ignition",
76  bool _cleanup = true);
77 
80  public: ~TempDirectory();
81 
85  public: bool Valid() const;
86 
93  public: void DoCleanup(bool _doCleanup);
94 
97  public: bool DoCleanup() const;
98 
101  public: std::string Path() const;
102 
105  private: std::unique_ptr<TempDirectoryPrivate> dataPtr;
107  };
108  } // namespace common
109 } // namespace ignition
110 #endif // IGNITION_COMMON_TEMPDIRECTORY_HH_
111 
Create a temporary directory in the OS temp location. Upon construction, the current working director...
Definition: TempDirectory.hh:62
#define IGN_COMMON_WARN_RESUME__DLL_INTERFACE_MISSING
Definition: SuppressWarning.hh:67
STL class.
Errors that occur during filesystem manipulation should be logged as warnings using ignwarn...
Definition: Filesystem.hh:37
std::string tempDirectoryPath()
Return the path to a directory suitable for temporary files.
FilesystemWarningOp
Options for how to handle errors that occur in functions that manipulate the filesystem.
Definition: Filesystem.hh:33
Forward declarations for the common classes.
std::string createTempDirectory(const std::string &_baseName, const std::string &_parentPath, const FilesystemWarningOp _warningOp=FSWO_LOG_WARNINGS)
Create a directory in the tempDirectoryPath by expanding a name template.
#define IGN_COMMON_WARN_IGNORE__DLL_INTERFACE_MISSING
Microsoft Visual Studio does not automatically export the interface information for member variables ...
Definition: SuppressWarning.hh:64