libzypp: zypp::filesystem::TmpPath Class Reference

libzypp 17.38.14

zypp::filesystem::TmpPath Class Reference

Automatically deletes files or directories when no longer needed. More...

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

Inheritance diagram for zypp::filesystem::TmpPath:

## Classes
class | Impl
| Clean or delete a directory on destruction. More...

## Public Member Functions
| 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 const Pathname & | defaultLocation ()

## Protected Attributes
RW_pointer< Impl > | _impl

## Detailed Description

Automatically deletes files or directories when no longer needed.

TmpPath is constructed from a Pathname. Multiple TmpPath instances created by copy and assign, share the same reference counted internal representation.

When the last reference drops any file or directory located at the path passed to the ctor is deleted (recursively in case of directories). This behavior can be changed by calling autoCleanup.

Principally serves as base class, but standalone usable.

Definition at line 37 of file TmpPath.h.

## Constructor & Destructor Documentation

## ◆ TmpPath() [1/2]

zypp::filesystem::TmpPath::TmpPath | ( |  | ) |

Default Ctor.

An empty Pathname.

Definition at line 107 of file TmpPath.cc.

## ◆ TmpPath() [2/2]

zypp::filesystem::TmpPath::TmpPath | ( | Pathname | tmpPath_r | ) |
| explicit

Ctor.

Takes a Pathname.

Definition at line 110 of file TmpPath.cc.

## ◆ ~TmpPath()

zypp::filesystem::TmpPath::~TmpPath | ( |  | ) |
| virtual

Dtor.

Definition at line 114 of file TmpPath.cc.

## Member Function Documentation

## ◆ operator bool()

zypp::filesystem::TmpPath::operator bool | ( |  | ) | const
| explicit

Test whether the Pathname is valid (i.e.

not empty. NOT whether it really denotes an existing file or directory).

Definition at line 119 of file TmpPath.cc.

## ◆ path()

Pathname zypp::filesystem::TmpPath::path | ( |  | ) | const

Returns
  The Pathname.

Definition at line 124 of file TmpPath.cc.

## ◆ operator Pathname()

zypp::filesystem::TmpPath::operator Pathname | ( |  | ) | const
| inline

Type conversion to Pathname.

Definition at line 69 of file TmpPath.h.

## ◆ autoCleanup() [1/2]

bool zypp::filesystem::TmpPath::autoCleanup | ( |  | ) | const

Whether path is valid and deleted when the last reference drops.

Definition at line 142 of file TmpPath.cc.

## ◆ autoCleanup() [2/2]

void zypp::filesystem::TmpPath::autoCleanup | ( | bool | yesno_r | ) |

Turn autoCleanup on/off if path is valid.

Definition at line 145 of file TmpPath.cc.

## ◆ defaultLocation()

const Pathname & zypp::filesystem::TmpPath::defaultLocation | ( |  | ) |
| static

Returns
  The default directory where temporary files should be are created: ($ZYPPTMPDIR|/var/tmp)/zypp.tmp/". \Note bsc#1249435: We use 'zypp.tmp' as a fix directory component to ease setting up SELinux policies.

Definition at line 129 of file TmpPath.cc.

## Member Data Documentation

## ◆ _impl

RW_pointer<Impl> zypp::filesystem::TmpPath::_impl
| protected

Definition at line 93 of file TmpPath.h.

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

- zypp-core/fs/TmpPath.h
- zypp-core/fs/TmpPath.cc