libzypp  17.38.7
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>
19 #include <zypp-core/ManagedFile.h>
20 
21 namespace 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  };
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  };
201 
202  } // namespace filesystem
203 
206 
207 } // namespace zypp
208 
209 #endif // ZYPP_CORE_FS_TMPPATH_H
String related utilities and Regular expression matching.
Provide a new empty temporary file and delete it when no longer needed.
Definition: TmpPath.h:117
std::ostream & operator<<(std::ostream &str, const Glob &obj)
relates: Glob Stream output
Definition: Glob.cc:53
Clean or delete a directory on destruction.
Definition: TmpPath.cc:38
Provide a new empty temporary directory and recursively delete it when no longer needed.
Definition: TmpPath.h:172
const Arch Arch_empty ZYPP_API
relates: Arch This is an empty Arch represented by an empty string.
Definition: Arch.h:173
RW_pointer< Impl > _impl
Definition: TmpPath.h:92
Automatically deletes files or directories when no longer needed.
Definition: TmpPath.h:37
Easy-to use interface to the ZYPP dependency resolver.
Definition: CodePitfalls.doc:1
Pathname myTmpDir()
Global access to the zypp.TMPDIR (created on demand, deleted when libzypp is unloaded) ...
Definition: TmpPath.cc:276