libzypp 17.37.17
zypp::filesystem::TmpFile Class Reference

Provide a new empty temporary file and delete it when no longer needed. More...

#include <zypp-core/fs/TmpPath.h>

Inheritance diagram for zypp::filesystem::TmpFile:

Public Member Functions

 TmpFile (const Pathname &inParentDir_r=defaultLocation(), const std::string &prefix_r=defaultPrefix())
 Ctor.
Public Member Functions inherited from zypp::filesystem::TmpPath
 TmpPath ()
 Default Ctor.
 TmpPath (Pathname tmpPath_r)
 Ctor.
virtual ~TmpPath ()
 Dtor.
 operator bool () const
 Test whether the Pathname is valid (i.e.
Pathname path () const
 operator Pathname () const
 Type conversion to Pathname.
bool autoCleanup () const
 Whether path is valid and deleted when the last reference drops.
void autoCleanup (bool yesno_r)
 Turn autoCleanup on/off if path is valid.

Static Public Member Functions

static TmpFile makeSibling (const Pathname &sibling_r)
 Provide a new empty temporary directory as sibling.
static TmpFile makeSibling (const Pathname &sibling_r, unsigned mode)
static ManagedFile asManagedFile ()
 Create a temporary file and convert it to a automatically cleaned up ManagedFile.
static ManagedFile asManagedFile (const Pathname &inParentDir_r, const std::string &prefix_r=defaultPrefix())
 Create a temporary file in inParentDir_r with prefix prefix_r and convert it to a automatically cleaned up ManagedFile.
static const std::string & defaultPrefix ()
Static Public Member Functions inherited from zypp::filesystem::TmpPath
static const PathnamedefaultLocation ()

Additional Inherited Members

Protected Attributes inherited from zypp::filesystem::TmpPath
RW_pointer< Impl_impl

Detailed Description

Provide a new empty temporary file and delete it when no longer needed.

The temporary file is per default created in '/var/tmp' and named 'TmpFile.XXXXXX', with XXXXXX replaced by a string which makes the name unique. Different location and file prefix may be passed to the ctor. TmpFile is created with mode 0600.

TmpFile provides the Pathname of the temporary file, or an empty path in case of any error.

Definition at line 127 of file TmpPath.h.

Constructor & Destructor Documentation

◆ TmpFile()

zypp::filesystem::TmpFile::TmpFile ( const Pathname & inParentDir_r = defaultLocation(),
const std::string & prefix_r = defaultPrefix() )
explicit

Ctor.

Takes a Pathname.

Definition at line 187 of file TmpPath.cc.

Member Function Documentation

◆ makeSibling() [1/2]

TmpFile zypp::filesystem::TmpFile::makeSibling ( const Pathname & sibling_r)
static

Provide a new empty temporary directory as sibling.

TmpFile s = makeSibling( "/var/lib/myfile" );
// returns: /var/lib/myfile.XXXXXX
TmpFile(const Pathname &inParentDir_r=defaultLocation(), const std::string &prefix_r=defaultPrefix())
Ctor.
Definition TmpPath.cc:187
static TmpFile makeSibling(const Pathname &sibling_r)
Provide a new empty temporary directory as sibling.
Definition TmpPath.cc:222

If sibling_r exists, sibling is created using the same mode.

Definition at line 222 of file TmpPath.cc.

◆ makeSibling() [2/2]

TmpFile zypp::filesystem::TmpFile::makeSibling ( const Pathname & sibling_r,
unsigned mode )
static

Definition at line 225 of file TmpPath.cc.

◆ asManagedFile() [1/2]

ManagedFile zypp::filesystem::TmpFile::asManagedFile ( )
static

Create a temporary file and convert it to a automatically cleaned up ManagedFile.

Definition at line 240 of file TmpPath.cc.

◆ asManagedFile() [2/2]

ManagedFile zypp::filesystem::TmpFile::asManagedFile ( const Pathname & inParentDir_r,
const std::string & prefix_r = defaultPrefix() )
static

Create a temporary file in inParentDir_r with prefix prefix_r and convert it to a automatically cleaned up ManagedFile.

Definition at line 245 of file TmpPath.cc.

◆ defaultPrefix()

const std::string & zypp::filesystem::TmpFile::defaultPrefix ( )
static
Returns
The default prefix for temporary files (TmpFile.)

Definition at line 259 of file TmpPath.cc.


The documentation for this class was generated from the following files: