00001 /*---------------------------------------------------------------------\ 00002 | | 00003 | __ __ ____ _____ ____ | 00004 | \ \ / /_ _/ ___|_ _|___ \ | 00005 | \ V / _` \___ \ | | __) | | 00006 | | | (_| |___) || | / __/ | 00007 | |_|\__,_|____/ |_| |_____| | 00008 | | 00009 | core system | 00010 | (C) SuSE Linux Products GmbH | 00011 \----------------------------------------------------------------------/ 00012 00013 File: TmpPath.h 00014 00015 Author: Michael Andres <ma@suse.de> 00016 Maintainer: Michael Andres <ma@suse.de> 00017 00018 Purpose: Provide temporary files/directories, automaticaly 00019 deleted when no longer needed. 00020 00021 /-*/ 00022 #ifndef TmpPath_h 00023 #define TmpPath_h 00024 00025 #include <iosfwd> 00026 00027 #include <y2util/Rep.h> 00028 #include <y2util/Pathname.h> 00029 00031 // 00032 // CLASS NAME : TmpPath 00044 class TmpPath 00045 { 00046 public: 00050 TmpPath(); 00051 00055 explicit 00056 TmpPath( const Pathname & tmpPath_r ); 00057 00061 virtual 00062 ~TmpPath(); 00063 00068 operator const void *const() const; 00069 00073 Pathname 00074 path() const; 00075 00079 operator Pathname() const 00080 { return path(); } 00081 00082 public: 00087 static const Pathname & 00088 defaultLocation(); 00089 00090 protected: 00091 class Impl; 00092 VarPtr<Impl> _impl; 00093 }; 00095 00099 inline std::ostream & 00100 operator<<( std::ostream & str, const TmpPath & obj ) 00101 { return str << static_cast<Pathname>(obj); } 00102 00104 00106 // 00107 // CLASS NAME : TmpFile 00121 class TmpFile : public TmpPath 00122 { 00123 public: 00127 explicit 00128 TmpFile( const Pathname & inParentDir_r = defaultLocation(), 00129 const std::string & prefix_r = defaultPrefix() ); 00130 00131 public: 00135 static const std::string & 00136 defaultPrefix(); 00137 00138 }; 00140 00142 // 00143 // CLASS NAME : TmpDir 00157 class TmpDir : public TmpPath 00158 { 00159 public: 00163 explicit 00164 TmpDir( const Pathname & inParentDir_r = defaultLocation(), 00165 const std::string & prefix_r = defaultPrefix() ); 00166 00167 public: 00171 static const std::string & 00172 defaultPrefix(); 00173 }; 00175 00176 #endif // TmpPath_h