libzypp  13.10.6
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 
20 namespace zypp {
21  namespace filesystem {
22 
24  //
25  // CLASS NAME : TmpPath
39  class TmpPath
40  {
41  public:
45  TmpPath();
46 
50  explicit
51  TmpPath( const Pathname & tmpPath_r );
52 
56  virtual
57  ~TmpPath();
58 
63  explicit operator bool() const;
64 
68  Pathname
69  path() const;
70 
74  operator Pathname() const
75  { return path(); }
76 
80  bool autoCleanup() const;
81 
85  void autoCleanup( bool yesno_r );
86 
87  public:
92  static const Pathname &
94 
95  protected:
96  class Impl;
98 
99  };
101 
105  inline std::ostream &
106  operator<<( std::ostream & str, const TmpPath & obj )
107  { return str << static_cast<Pathname>(obj); }
108 
110 
112  //
113  // CLASS NAME : TmpFile
126  class TmpFile : public TmpPath
127  {
128  public:
132  explicit
133  TmpFile( const Pathname & inParentDir_r = defaultLocation(),
134  const std::string & prefix_r = defaultPrefix() );
135 
143  static TmpFile makeSibling( const Pathname & sibling_r );
144 
145  public:
149  static const std::string &
150  defaultPrefix();
151 
152  };
154 
156  //
157  // CLASS NAME : TmpDir
170  class TmpDir : public TmpPath
171  {
172  public:
176  explicit
177  TmpDir( const Pathname & inParentDir_r = defaultLocation(),
178  const std::string & prefix_r = defaultPrefix() );
179 
187  static TmpDir makeSibling( const Pathname & sibling_r );
188 
189  public:
193  static const std::string &
194  defaultPrefix();
195  };
197 
198  } // namespace filesystem
199 } // namespace zypp
200 
201 #endif // ZYPP_TMPPATH_H
TmpFile(const Pathname &inParentDir_r=defaultLocation(), const std::string &prefix_r=defaultPrefix())
Ctor.
Definition: TmpPath.cc:181
Pathname path() const
Definition: TmpPath.cc:146
static TmpDir makeSibling(const Pathname &sibling_r)
Provide a new empty temporary directory as sibling.
Definition: TmpPath.cc:287
TmpPath()
Default Ctor.
Definition: TmpPath.cc:108
static const Pathname & defaultLocation()
Definition: TmpPath.cc:157
TmpDir(const Pathname &inParentDir_r=defaultLocation(), const std::string &prefix_r=defaultPrefix())
Ctor.
Definition: TmpPath.cc:253
Provide a new empty temporary file and delete it when no longer needed.
Definition: TmpPath.h:126
Clean or delete a directory on destruction.
Definition: TmpPath.cc:36
Provide a new empty temporary directory and recursively delete it when no longer needed.
Definition: TmpPath.h:170
static const std::string & defaultPrefix()
Definition: TmpPath.cc:236
virtual ~TmpPath()
Dtor.
Definition: TmpPath.cc:125
Wrapper for const correct access via Smart pointer types.
Definition: PtrTypes.h:265
RW_pointer< Impl > _impl
Definition: TmpPath.h:96
Automaticaly deletes files or directories when no longer needed.
Definition: TmpPath.h:39
static TmpFile makeSibling(const Pathname &sibling_r)
Provide a new empty temporary directory as sibling.
Definition: TmpPath.cc:218
bool autoCleanup() const
Whether path is valid and deleted when the last reference drops.
Definition: TmpPath.cc:163
std::ostream & operator<<(std::ostream &str, const Glob &obj)
Definition: Glob.cc:53
static const std::string & defaultPrefix()
Definition: TmpPath.cc:305