libzypp 17.38.1
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>
20
21namespace zypp {
22 namespace filesystem {
23
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;
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
206
207} // namespace zypp
208
209#endif // ZYPP_CORE_FS_TMPPATH_H
#define ZYPP_API
Definition Globals.h:69
static const std::string & defaultPrefix()
Definition TmpPath.cc:268
TmpDir(const Pathname &inParentDir_r=defaultLocation(), const std::string &prefix_r=defaultPrefix())
Ctor.
Definition TmpPath.cc:223
static TmpDir makeSibling(const Pathname &sibling_r)
Provide a new empty temporary directory as sibling.
Definition TmpPath.cc:250
TmpFile(const Pathname &inParentDir_r=defaultLocation(), const std::string &prefix_r=defaultPrefix())
Ctor.
Definition TmpPath.cc:152
static TmpFile makeSibling(const Pathname &sibling_r)
Provide a new empty temporary directory as sibling.
Definition TmpPath.cc:182
static ManagedFile asManagedFile()
Create a temporary file and convert it to a automatically cleaned up ManagedFile.
Definition TmpPath.cc:200
static const std::string & defaultPrefix()
Definition TmpPath.cc:213
static const Pathname & defaultLocation()
Definition TmpPath.cc:129
RW_pointer< Impl > _impl
Definition TmpPath.h:93
std::ostream & operator<<(std::ostream &str, const TmpPath &obj)
Stream output as pathname.
Definition TmpPath.h:100
Pathname path() const
Definition TmpPath.cc:124
TmpPath()
Default Ctor.
Definition TmpPath.cc:107
String related utilities and Regular expression matching.
Types and functions for filesystem operations.
Definition PathInfo.cc:41
Pathname myTmpDir()
Global access to the zypp.TMPDIR (created on demand, deleted when libzypp is unloaded).
Definition TmpPath.cc:276
AutoDispose< const Pathname > ManagedFile
A Pathname plus associated cleanup code to be executed when path is no longer needed.
Definition ManagedFile.h:27
Wrapper for const correct access via Smart pointer types.
Definition PtrTypes.h:293