libzypp: zypp/TmpPath.h Source File

libzypp 17.25.10

TmpPath.h
Go to the documentation of this file.
1 /*---------------------------------------------------------------------\
2 | ____ _ __ __ ___ |
3 | |__ / \ / / . \ . \ |
4 | / / \ V /| _/ _/ |
5 | / /__ | | | | | | |
6 | /_____||_| |_| |_| |
7 | |
8 \---------------------------------------------------------------------*/
12 #ifndef ZYPP_TMPPATH_H
13 #define ZYPP_TMPPATH_H
14
15 #include <iosfwd>
16
17 #include <zypp/Pathname.h>
18 #include <zypp/base/PtrTypes.h>
19 #include <zypp/ManagedFile.h>
20
21 namespace zypp {
22 namespace filesystem {
23
25 //
26 // CLASS NAME : TmpPath
40 class TmpPath
41 {
42 public:
46 TmpPath();
47
51 explicit
52 TmpPath( const Pathname & tmpPath_r );
53
57 virtual
58 ~TmpPath();
59
64 explicit operator bool() const;
65
69 Pathname
70 path() const;
71
75 operator Pathname() const
76 { return path(); }
77
81 bool autoCleanup() const;
82
86 void autoCleanup( bool yesno_r );
87
88 public:
93 static const Pathname &
94 defaultLocation();
95
96 protected:
97 class Impl;
98 RW_pointer<Impl> _impl;
99
100 };
102
106 inline std::ostream &
107 operator<<( std::ostream & str, const TmpPath & obj )
108 { return str << static_cast<Pathname>(obj); }
109
111
113 //
114 // CLASS NAME : TmpFile
127 class TmpFile : public TmpPath
128 {
129 public:
133 explicit
134 TmpFile( const Pathname & inParentDir_r = defaultLocation(),
135 const std::string & prefix_r = defaultPrefix() );
136
144 static TmpFile makeSibling( const Pathname & sibling_r );
145
150 static ManagedFile asManagedFile ();
151
152 public:
156 static const std::string &
157 defaultPrefix();
158
159 };
161
163 //
164 // CLASS NAME : TmpDir
177 class TmpDir : public TmpPath
178 {
179 public:
183 explicit
184 TmpDir( const Pathname & inParentDir_r = defaultLocation(),
185 const std::string & prefix_r = defaultPrefix() );
186
194 static TmpDir makeSibling( const Pathname & sibling_r );
195
196 public:
200 static const std::string &
201 defaultPrefix();
202 };
204
205 } // namespace filesystem
206
208 Pathname myTmpDir(); // implemented in ZYppImpl.cc
209
210 } // namespace zypp
211
212 #endif // ZYPP_TMPPATH_H
ManagedFile.h
Pathname.h
PtrTypes.h
Impl
zypp::AutoDispose
Reference counted access to a Tp object calling a custom Dispose function when the last AutoDispose h...
Definition: AutoDispose.h:93
zypp::filesystem::Pathname
Pathname.
Definition: Pathname.h:45
zypp::filesystem::TmpDir
Provide a new empty temporary directory and recursively delete it when no longer needed.
Definition: TmpPath.h:178
zypp::filesystem::TmpDir::defaultPrefix
static const std::string & defaultPrefix()
Definition: TmpPath.cc:313
zypp::filesystem::TmpDir::TmpDir
TmpDir(const Pathname &inParentDir_r=defaultLocation(), const std::string &prefix_r=defaultPrefix())
Ctor.
Definition: TmpPath.cc:261
zypp::filesystem::TmpDir::makeSibling
static TmpDir makeSibling(const Pathname &sibling_r)
Provide a new empty temporary directory as sibling.
Definition: TmpPath.cc:295
zypp::filesystem::TmpFile
Provide a new empty temporary file and delete it when no longer needed.
Definition: TmpPath.h:128
zypp::filesystem::TmpFile::TmpFile
TmpFile(const Pathname &inParentDir_r=defaultLocation(), const std::string &prefix_r=defaultPrefix())
Ctor.
Definition: TmpPath.cc:181
zypp::filesystem::TmpFile::makeSibling
static TmpFile makeSibling(const Pathname &sibling_r)
Provide a new empty temporary directory as sibling.
Definition: TmpPath.cc:218
zypp::filesystem::TmpFile::asManagedFile
static ManagedFile asManagedFile()
Create a temporary file and convert it to a automatically cleaned up ManagedFile.
Definition: TmpPath.cc:230
zypp::filesystem::TmpFile::defaultPrefix
static const std::string & defaultPrefix()
Definition: TmpPath.cc:244
zypp::filesystem::TmpPath
Automaticaly deletes files or directories when no longer needed.
Definition: TmpPath.h:41
zypp::filesystem::TmpPath::defaultLocation
static const Pathname & defaultLocation()
Definition: TmpPath.cc:157
zypp::filesystem::TmpPath::_impl
RW_pointer< Impl > _impl
Definition: TmpPath.h:97
zypp::filesystem::TmpPath::~TmpPath
virtual ~TmpPath()
Dtor.
Definition: TmpPath.cc:125
zypp::filesystem::TmpPath::path
Pathname path() const
Definition: TmpPath.cc:146
zypp::filesystem::TmpPath::TmpPath
TmpPath()
Default Ctor.
Definition: TmpPath.cc:108
zypp::filesystem::TmpPath::autoCleanup
bool autoCleanup() const
Whether path is valid and deleted when the last reference drops.
Definition: TmpPath.cc:163
str
String related utilities and Regular expression matching.
zypp::filesystem::operator<<
std::ostream & operator<<(std::ostream &str, const Glob &obj)
Definition: Glob.cc:53
zypp
Easy-to use interface to the ZYPP dependency resolver.
Definition: CodePitfalls.doc:2
zypp::ResolverNamespace::filesystem
@ filesystem
filesystems
zypp::myTmpDir
Pathname myTmpDir()
Global access to the zypp.TMPDIR (created on demand, deleted when libzypp is unloaded)
Definition: ZYppImpl.cc:228
zypp::RW_pointer
Wrapper for const correct access via Smart pointer types.
Definition: PtrTypes.h:286