28 namespace filesystem {
46 CtorDefault = Autodelete
52 : _path( path_r ), _flags( flags_r )
57 if ( ! (_flags & Autodelete) || _path.empty() )
60 PathInfo p( _path, PathInfo::LSTAT );
67 if ( _flags & KeepTopdir )
76 INT <<
"TmpPath cleanup error (" << res <<
") " << p << endl;
78 DBG <<
"TmpPath cleaned up " << p << endl;
85 bool autoCleanup()
const
86 {
return( _flags & Autodelete ); }
88 void autoCleanup(
bool yesno_r )
89 { _flags = yesno_r ? CtorDefault : NoOp; }
119 :_impl( tmpPath_r.empty() ? 0 : new
Impl( tmpPath_r ) )
138 TmpPath::operator
const void * ()
const
162 static Pathname p( getenv(
"ZYPPTMPDIR") ? getenv(
"ZYPPTMPDIR") :
"/var/tmp" );
185 const std::string & prefix_r )
190 ERR <<
"Parent directory '" << inParentDir_r <<
"' can't be created." << endl;
195 Pathname tmpPath = (inParentDir_r + prefix_r).extend(
"XXXXXX");
196 char * buf = ::strdup( tmpPath.
asString().c_str() );
199 ERR <<
"Out of memory" << endl;
203 int tmpFd = ::mkostemp( buf, O_CLOEXEC );
211 ERR <<
"Cant create '" << buf <<
"' " <<
::strerror( errno ) << endl;
228 ::chmod( ret.path().c_str(), p.st_mode() );
241 static string p(
"TmpFile." );
257 const std::string & prefix_r )
262 ERR <<
"Parent directory '" << inParentDir_r <<
"' can't be created." << endl;
267 Pathname tmpPath = (inParentDir_r + prefix_r).extend(
"XXXXXX");
268 char * buf = ::strdup( tmpPath.
asString().c_str() );
271 ERR <<
"Out of memory" << endl;
275 char * tmp = ::mkdtemp( buf );
280 ERR <<
"Cant create '" << tmpPath <<
"' " <<
::strerror( errno ) << endl;
297 ::chmod( ret.path().c_str(), p.st_mode() );
310 static string p(
"TmpDir." );