20#include <zypp-core/base/ReferenceCounted.h>
21#include <zypp-core/base/NonCopyable.h>
22#include <zypp-core/base/Logger.h>
23#include <zypp-core/fs/PathInfo.h>
24#include <zypp-core/fs/TmpPath.h>
80 INT <<
"TmpPath cleanup error (" <<
res <<
") " <<
p << endl;
82 DBG <<
"TmpPath cleaned up " <<
p << endl;
168 {
return _impl.get() ?
_impl->autoCleanup() :
false; }
191 ERR <<
"Parent directory '" <<
inParentDir_r <<
"' can't be created." << endl;
197 char *
buf = ::strdup( tmpPath.
asString().c_str() );
200 ERR <<
"Out of memory" << endl;
212 ERR <<
"Cant create '" <<
buf <<
"' " << ::strerror(
errno ) << endl;
250 static std::string
p(
"TmpFile." );
271 ERR <<
"Parent directory '" <<
inParentDir_r <<
"' can't be created." << endl;
277 char *
buf = ::strdup( tmpPath.
asString().c_str() );
280 ERR <<
"Out of memory" << endl;
284 char *
tmp = ::mkdtemp(
buf );
289 ERR <<
"Cant create '" << tmpPath <<
"' " << ::strerror(
errno ) << endl;
319 static std::string
p(
"TmpDir." );
Reference counted access to a Tp object calling a custom Dispose function when the last AutoDispose h...
Base class for reference counted objects.
Wrapper class for stat/lstat.
const std::string & asString() const
String representation.
bool empty() const
Test for an empty path.
Provide a new empty temporary directory and recursively delete it when no longer needed.
static const std::string & defaultPrefix()
TmpDir(const Pathname &inParentDir_r=defaultLocation(), const std::string &prefix_r=defaultPrefix())
Ctor.
static TmpDir makeSibling(const Pathname &sibling_r)
Provide a new empty temporary directory as sibling.
Provide a new empty temporary file and delete it when no longer needed.
TmpFile(const Pathname &inParentDir_r=defaultLocation(), const std::string &prefix_r=defaultPrefix())
Ctor.
static TmpFile makeSibling(const Pathname &sibling_r)
Provide a new empty temporary directory as sibling.
static ManagedFile asManagedFile()
Create a temporary file and convert it to a automatically cleaned up ManagedFile.
static const std::string & defaultPrefix()
Clean or delete a directory on destruction.
Impl & operator=(const Impl &)=delete
void autoCleanup(bool yesno_r)
Impl(Pathname &&path_r, Flags flags_r=CtorDefault)
Impl & operator=(Impl &&)=delete
Impl(const Impl &)=delete
const Pathname & path() const
static const Pathname & defaultLocation()
bool autoCleanup() const
Whether path is valid and deleted when the last reference drops.
boost::noncopyable NonCopyable
Ensure derived classes cannot be copied.
int chmod(const Pathname &path, mode_t mode)
Like 'chmod'.
int unlink(const Pathname &path)
Like 'unlink'.
int recursive_rmdir(const Pathname &path)
Like 'rm -r DIR'.
int assert_dir(const Pathname &path, unsigned mode)
Like 'mkdir -p'.
int clean_dir(const Pathname &path)
Like 'rm -r DIR/ *'.
Easy-to use interface to the ZYPP dependency resolver.