Go to the documentation of this file.
76 INT <<
"TmpPath cleanup error (" << res <<
") " << p << endl;
78 DBG <<
"TmpPath cleaned up " << p << endl;
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;
246 static std::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;
315 static std::string p(
"TmpDir." );
int assert_dir(const Pathname &path, unsigned mode)
Like 'mkdir -p'.
static ManagedFile asManagedFile()
Create a temporary file and convert it to a automatically cleaned up ManagedFile.
bool isExist() const
Return whether valid stat info exists.
int clean_dir(const Pathname &path)
Like 'rm -r DIR/ *'.
static const Pathname & defaultLocation()
TmpFile(const Pathname &inParentDir_r=defaultLocation(), const std::string &prefix_r=defaultPrefix())
Ctor.
Base class for reference counted objects.
int recursive_rmdir(const Pathname &path)
Like 'rm -r DIR'.
@ language
language support
int chmod(const Pathname &path, mode_t mode)
Like 'chmod'.
std::string strerror(int errno_r)
Return string describing the error_r code.
static const std::string & defaultPrefix()
int unlink(const Pathname &path)
Like 'unlink'.
static const std::string & defaultPrefix()
Impl(const Pathname &path_r, Flags flags_r=CtorDefault)
void autoCleanup(bool yesno_r)
Clean or delete a directory on destruction.
Wrapper class for ::stat/::lstat.
Provide a new empty temporary file and delete it when no longer needed.
static TmpDir makeSibling(const Pathname &sibling_r)
Provide a new empty temporary directory as sibling.
Provide a new empty temporary directory and recursively delete it when no longer needed.
const char * c_str() const
String representation.
boost::noncopyable NonCopyable
Ensure derived classes cannot be copied.
Easy-to use interface to the ZYPP dependency resolver.
TmpDir(const Pathname &inParentDir_r=defaultLocation(), const std::string &prefix_r=defaultPrefix())
Ctor.
Reference counted access to a Tp object calling a custom Dispose function when the last AutoDispose h...
Pathname dirname() const
Return all but the last component od this path.
bool empty() const
Test for an empty path.
std::string basename() const
Return the last component of this path.
const std::string & asString() const
String representation.
bool autoCleanup() const
Whether path is valid and deleted when the last reference drops.
static TmpFile makeSibling(const Pathname &sibling_r)
Provide a new empty temporary directory as sibling.
const Pathname & path() const