qBittorrent
FileGuard Class Reference

Utility class to defer file deletion. More...

#include <torrentfileguard.h>

Inheritance diagram for FileGuard:

Public Member Functions

 FileGuard (const QString &path={})
 
 ~FileGuard ()
 
void setAutoRemove (bool remove) noexcept
 Cancels or re-enables deferred file deletion. More...
 

Private Attributes

QString m_path
 
bool m_remove
 

Detailed Description

Utility class to defer file deletion.

Definition at line 37 of file torrentfileguard.h.

Constructor & Destructor Documentation

◆ FileGuard()

FileGuard::FileGuard ( const QString &  path = {})
explicit

Definition at line 34 of file torrentfileguard.cpp.

35  : m_path {path}
36  , m_remove {true}
37 {
38 }
QString m_path

◆ ~FileGuard()

FileGuard::~FileGuard ( )

Definition at line 45 of file torrentfileguard.cpp.

46 {
47  if (m_remove && !m_path.isEmpty())
48  Utils::Fs::forceRemove(m_path); // forceRemove() checks for file existence
49 }
bool forceRemove(const QString &filePath)
Definition: fs.cpp:173

References Utils::Fs::forceRemove(), m_path, and m_remove.

Here is the call graph for this function:

Member Function Documentation

◆ setAutoRemove()

void FileGuard::setAutoRemove ( bool  remove)
noexcept

Cancels or re-enables deferred file deletion.

Definition at line 40 of file torrentfileguard.cpp.

41 {
42  m_remove = remove;
43 }

Member Data Documentation

◆ m_path

QString FileGuard::m_path
private

Definition at line 47 of file torrentfileguard.h.

Referenced by ~FileGuard().

◆ m_remove

bool FileGuard::m_remove
private

Definition at line 48 of file torrentfileguard.h.

Referenced by ~FileGuard().


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