KJB
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
Public Member Functions | List of all members
kjb::Temporary_Directory Class Reference

this class creates a temporary directory under TEMP_DIR (usu. /tmp) More...

#include <l_stdio_wrap.h>

Inheritance diagram for kjb::Temporary_Directory:
kjb::Temporary_Recursively_Removing_Directory

Public Member Functions

 Temporary_Directory ()
 
int remove ()
 
int recursively_remove ()
 
const std::string & get_pathname () const
 get the filename of this object (if still valid) More...
 
bool set_silence_flag (bool new_silence_setting=true)
 By default the dtor prints errors (if any) – you can suppress it. More...
 

Detailed Description

this class creates a temporary directory under TEMP_DIR (usu. /tmp)

If the directory is empty at destruction time, this removes the directory. If the directory is not empty, this sets errno and maybe prints a message, but does not throw. If you need to clear out the directory prior to destruction then consider calling the recursively_remove() method, or use class Temporary_Recursively_Removing_Directory.

The default behavior of the class is for the destructor to print if it is unable to succeed. If you do not want the destructor to print, regardless of error status, use the method set_silence_flag(). This same method returns the prior state of the flag.

Constructor & Destructor Documentation

kjb::Temporary_Directory::Temporary_Directory ( )
inline

Member Function Documentation

const std::string& kjb::Temporary_Directory::get_pathname ( ) const
inline

get the filename of this object (if still valid)

Iff either cleanup method has succeeded previously, then this method returns a reference to an empty string, indicating that the underlying file is gone.

int kjb::Temporary_Directory::recursively_remove ( )
inline
int kjb::Temporary_Directory::remove ( )
inline
bool kjb::Temporary_Directory::set_silence_flag ( bool  new_silence_setting = true)
inline

By default the dtor prints errors (if any) – you can suppress it.

Parameters
new_silence_settingif false, and if the (future) destruction step fails, the destructor will print the relevant error message. If true, nothing will be printed.
Returns
previous value of the flag

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