libzypp 17.38.15

TmpPath.h
Go to the documentation of this file.
1/*---------------------------------------------------------------------\
2| ____ _ __ __ ___ |
3| |__ / \ / / . \ . \ |
4| / / \ V /| _/ _/ |
5| / /__ | | | | | | |
6| /_____||_| |_| |_| |
7| |
8\---------------------------------------------------------------------*/
12#ifndef ZYPP_CORE_FS_TMPPATH_H
13#define ZYPP_CORE_FS_TMPPATH_H
14
15#include <iosfwd>
16
17#include <zypp-core/Pathname.h>
18#include <zypp-core/base/PtrTypes.h>
19#include <zypp-core/ManagedFile.h>
20
21 namespace zypp {
22 namespace filesystem {
23
37 class ZYPP_API TmpPath
38 {
39 public:
43 TmpPath();
44
48 explicit TmpPath( Pathname tmpPath_r );
49
53 virtual ~TmpPath();
54
59 explicit operator bool() const;
60
64 Pathname path() const;
65
69 operator Pathname() const
70 { return path(); }
71
75 bool autoCleanup() const;
76
80 void autoCleanup( bool yesno_r );
81
82 public:
89 static const Pathname & defaultLocation();
90
91 protected:
92 class Impl;
93 RW_pointer<Impl> _impl;
94
95 };
96
100 inline std::ostream & operator<<( std::ostream & str, const TmpPath & obj )
101 { return str << static_cast<Pathname>(obj); }
102
104
117 class ZYPP_API TmpFile : public TmpPath
118 {
119 public:
123 explicit TmpFile( const Pathname & inParentDir_r = defaultLocation(),
124 const std::string & prefix_r = defaultPrefix() );
125
133 static TmpFile makeSibling( const Pathname & sibling_r );
137 static TmpFile makeSibling( const Pathname & sibling_r, unsigned mode );
138
143 static ManagedFile asManagedFile ();
144
149 static ManagedFile asManagedFile ( const Pathname & inParentDir_r, const std::string & prefix_r = defaultPrefix() );
150
151 public:
155 static const std::string & defaultPrefix();
156
157 };
158
159
172 class ZYPP_API TmpDir : public TmpPath
173 {
174 public:
178 explicit TmpDir( const Pathname & inParentDir_r = defaultLocation(),
179 const std::string & prefix_r = defaultPrefix() );
180
188 static TmpDir makeSibling( const Pathname & sibling_r );
192 static TmpDir makeSibling( const Pathname & sibling_r, unsigned mode );
193
194 public:
198 static const std::string & defaultPrefix();
199 };
200
201
202 } // namespace filesystem
203
205 Pathname myTmpDir() ZYPP_API;
206
207} // namespace zypp
208
209#endif // ZYPP_CORE_FS_TMPPATH_H
Pathname.h
PtrTypes.h
Impl
bool
zypp::filesystem::Pathname
Pathname.
Definition Pathname.h:48
zypp::filesystem::TmpDir::defaultPrefix
static const std::string & defaultPrefix()
Definition TmpPath.cc:268
zypp::filesystem::TmpDir::TmpDir
TmpDir(const Pathname &inParentDir_r=defaultLocation(), const std::string &prefix_r=defaultPrefix())
Ctor.
Definition TmpPath.cc:223
zypp::filesystem::TmpDir::makeSibling
static TmpDir makeSibling(const Pathname &sibling_r)
Provide a new empty temporary directory as sibling.
Definition TmpPath.cc:250
zypp::filesystem::TmpFile::TmpFile
TmpFile(const Pathname &inParentDir_r=defaultLocation(), const std::string &prefix_r=defaultPrefix())
Ctor.
Definition TmpPath.cc:152
zypp::filesystem::TmpFile::makeSibling
static TmpFile makeSibling(const Pathname &sibling_r)
Provide a new empty temporary directory as sibling.
Definition TmpPath.cc:182
zypp::filesystem::TmpFile::asManagedFile
static ManagedFile asManagedFile()
Create a temporary file and convert it to a automatically cleaned up ManagedFile.
Definition TmpPath.cc:200
zypp::filesystem::TmpFile::defaultPrefix
static const std::string & defaultPrefix()
Definition TmpPath.cc:213
zypp::filesystem::TmpPath
Automatically deletes files or directories when no longer needed.
Definition TmpPath.h:38
zypp::filesystem::TmpPath::defaultLocation
static const Pathname & defaultLocation()
Definition TmpPath.cc:129
zypp::filesystem::TmpPath::_impl
RW_pointer< Impl > _impl
Definition TmpPath.h:93
zypp::filesystem::TmpPath::path
Pathname path() const
Definition TmpPath.cc:124
zypp::filesystem::TmpPath::TmpPath
TmpPath()
Default Ctor.
Definition TmpPath.cc:107
str
String related utilities and Regular expression matching.
zypp::filesystem
Types and functions for filesystem operations.
Definition Glob.cc:24
zypp::filesystem::operator<<
std::ostream & operator<<(std::ostream &str, const Glob &obj)
relates: Glob Stream output
Definition Glob.cc:53
zypp
Easy-to use interface to the ZYPP dependency resolver.
Definition CodePitfalls.doc:2
zypp::myTmpDir
Pathname myTmpDir()
Global access to the zypp.TMPDIR (created on demand, deleted when libzypp is unloaded).
Definition TmpPath.cc:276
zypp::ManagedFile
AutoDispose< const Pathname > ManagedFile
A Pathname plus associated cleanup code to be executed when path is no longer needed.
Definition ManagedFile.h:27
zypp::ZYPP_API
const Arch Arch_empty ZYPP_API
relates: Arch This is an empty Arch represented by an empty string.
Definition Arch.h:173
zypp::RW_pointer
Wrapper for const correct access via Smart pointer types.
Definition PtrTypes.h:293
ManagedFile.h