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; }
117 :_impl( tmpPath_r.empty() ?
nullptr : new
Impl( tmpPath_r ) )
159 static Pathname p( getenv(
"ZYPPTMPDIR") ? getenv(
"ZYPPTMPDIR") :
"/var/tmp" );
182 const std::string & prefix_r )
187 ERR <<
"Parent directory '" << inParentDir_r <<
"' can't be created." << endl;
192 Pathname tmpPath = (inParentDir_r + prefix_r).extend(
"XXXXXX");
193 char * buf = ::strdup( tmpPath.
asString().c_str() );
196 ERR <<
"Out of memory" << endl;
200 int tmpFd = ::mkostemp( buf, O_CLOEXEC );
208 ERR <<
"Cant create '" << buf <<
"' " <<
::strerror( errno ) << endl;
225 ::chmod( ret.path().c_str(), p.st_mode() );
246 static string p(
"TmpFile." );
262 const std::string & prefix_r )
267 ERR <<
"Parent directory '" << inParentDir_r <<
"' can't be created." << endl;
272 Pathname tmpPath = (inParentDir_r + prefix_r).extend(
"XXXXXX");
273 char * buf = ::strdup( tmpPath.
asString().c_str() );
276 ERR <<
"Out of memory" << endl;
280 char * tmp = ::mkdtemp( buf );
285 ERR <<
"Cant create '" << tmpPath <<
"' " <<
::strerror( errno ) << endl;
302 ::chmod( ret.path().c_str(), p.st_mode() );
315 static string p(
"TmpDir." );