KiCad PCB EDA Suite
Loading...
Searching...
No Matches
KI_TEST::SCOPED_PROCESS_TEMP_DIR Class Reference

Install a temporary directory for the process to use for temporary files, which is (usually) removed on destruction. More...

#include <file_utils.h>

Public Member Functions

 SCOPED_PROCESS_TEMP_DIR (const wxString &aPrefix)
 
 ~SCOPED_PROCESS_TEMP_DIR ()
 
 SCOPED_PROCESS_TEMP_DIR (const SCOPED_PROCESS_TEMP_DIR &)=delete
 
SCOPED_PROCESS_TEMP_DIRoperator= (const SCOPED_PROCESS_TEMP_DIR &)=delete
 

Private Attributes

SCOPED_TEMP_DIR m_dir
 

Detailed Description

Install a temporary directory for the process to use for temporary files, which is (usually) removed on destruction.

Declare this early in the test program, before any use of temporary directories.

Both ends of its life can be outside the wx lifetime, so its constructor and destructor make no wx logging calls: messages about kept or undeletable directories go to stderr.

The redirect applies to wxFileName and std::filesystem temp paths, but won't affect hardcoded paths (which should be avoided anyway).

This will then automatically tidy up any files created by temp dir functions as in wxFileName and std::filesystem, even if not properly scoped in a SCOPED_TEMP_DIR.

The directory is kept whenever any temporary directory created by SCOPED_TEMP_DIR is kept.

Definition at line 178 of file file_utils.h.

Constructor & Destructor Documentation

◆ SCOPED_PROCESS_TEMP_DIR() [1/2]

SCOPED_PROCESS_TEMP_DIR::SCOPED_PROCESS_TEMP_DIR ( const wxString & aPrefix)

Definition at line 205 of file file_utils.cpp.

References m_dir.

Referenced by operator=(), and SCOPED_PROCESS_TEMP_DIR().

◆ ~SCOPED_PROCESS_TEMP_DIR()

SCOPED_PROCESS_TEMP_DIR::~SCOPED_PROCESS_TEMP_DIR ( )

Definition at line 216 of file file_utils.cpp.

References KI_TEST::SCOPED_TEMP_DIR::AnyTempDirRetained(), and m_dir.

◆ SCOPED_PROCESS_TEMP_DIR() [2/2]

KI_TEST::SCOPED_PROCESS_TEMP_DIR::SCOPED_PROCESS_TEMP_DIR ( const SCOPED_PROCESS_TEMP_DIR & )
delete

Member Function Documentation

◆ operator=()

SCOPED_PROCESS_TEMP_DIR & KI_TEST::SCOPED_PROCESS_TEMP_DIR::operator= ( const SCOPED_PROCESS_TEMP_DIR & )
delete

Member Data Documentation

◆ m_dir

SCOPED_TEMP_DIR KI_TEST::SCOPED_PROCESS_TEMP_DIR::m_dir
private

Definition at line 189 of file file_utils.h.

Referenced by SCOPED_PROCESS_TEMP_DIR(), and ~SCOPED_PROCESS_TEMP_DIR().


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