softwarecontainer  0.18.0-739e8d7 2017-05-04
softwarecontainer::FileCleanUpHandler Class Reference

The FileCleanUpHandler class is a subclass of CleanUpHandler that deletes a file. More...

#include <filecleanuphandler.h>

Inheritance diagram for softwarecontainer::FileCleanUpHandler:
[legend]
Collaboration diagram for softwarecontainer::FileCleanUpHandler:
[legend]

Public Member Functions

 FileCleanUpHandler (const std::string &path)
 FileCleanUpHandler Create a cleanupHandler for the Path, which will be deleted when running the clean() function. More...
 
bool clean () override
 clean Perform the cleanupHandler clean. More...
 
const std::string queryName () override
 this function is needed to query member name More...
 

Data Fields

std::string m_path
 

Protected Member Functions

 LOG_DECLARE_CLASS_CONTEXT ("CLEA","Cleanup handler")
 

Detailed Description

The FileCleanUpHandler class is a subclass of CleanUpHandler that deletes a file.

It is most commonly used when the FileToolKitWithUndo destructor is run to clean away cruft from the filesystem

Definition at line 31 of file filecleanuphandler.h.

Constructor & Destructor Documentation

softwarecontainer::FileCleanUpHandler::FileCleanUpHandler ( const std::string &  path)

FileCleanUpHandler Create a cleanupHandler for the Path, which will be deleted when running the clean() function.

Parameters
pathThe path of the file to delete when clean() is run.

Definition at line 24 of file filecleanuphandler.cpp.

25 {
26  m_path = path;
27 }

Member Function Documentation

bool softwarecontainer::FileCleanUpHandler::clean ( )
overridevirtual

clean Perform the cleanupHandler clean.

Returns
true on success
false on failure

Implements softwarecontainer::CleanUpHandler.

Definition at line 29 of file filecleanuphandler.cpp.

30 {
31  if (unlink(m_path.c_str()) == 0) {
32  log_debug() << "Unlinked " << m_path;
33  return true;
34  } else {
35  log_error() << "Can't delete " << m_path << " . Error :" << strerror(errno);
36  return false;
37  }
38 }
const std::string softwarecontainer::FileCleanUpHandler::queryName ( )
overridevirtual

this function is needed to query member name

Returns
a read-only m_path

Implements softwarecontainer::CleanUpHandler.

Definition at line 40 of file filecleanuphandler.cpp.

41 {
42  return m_path;
43 }

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