ProvSQL C/C++ API
Adding support for provenance and uncertainty management to PostgreSQL databases
Loading...
Searching...
No Matches
ScopedTempDir Class Reference

RAII guard around a freshly mkdtemp'd /tmp directory. More...

#include "scoped_tempdir.h"

Public Member Functions

 ScopedTempDir ()
 ScopedTempDir (const ScopedTempDir &)=delete
 ~ScopedTempDir ()
ScopedTempDiroperator= (const ScopedTempDir &)=delete
std::string file (const std::string &basename)
 Build a path under the temp dir and register it for cleanup.
void track (const std::string &p)
 Also track a file we did not create through file() (e.g.
void keep ()
 Leave the directory on disk; cleanup is skipped at scope exit.
const std::string & path () const

Private Attributes

std::string path_
std::vector< std::string > files_
bool keep_ = false

Detailed Description

RAII guard around a freshly mkdtemp'd /tmp directory.

Wraps the boilerplate every external-tool launch shares: create a private 0700 directory, write the Tseytin CNF and any sibling files into it, and on scope exit unlink each tracked file and rmdir the directory. If the body throws (missing tool, runtime failure, malformed output), the destructor still runs and the /tmp leak is avoided. Pass keep() in the verbose-debug arm to leave the artifacts on disk for inspection.

Best-effort: the destructor swallows unlink/rmdir errors because it must not throw during stack unwinding.

Definition at line 29 of file scoped_tempdir.h.

Constructor & Destructor Documentation

◆ ScopedTempDir() [1/2]

Definition at line 31 of file scoped_tempdir.h.

◆ ScopedTempDir() [2/2]

◆ ~ScopedTempDir()

Definition at line 37 of file scoped_tempdir.h.

Member Function Documentation

◆ file()

std::string provsql::ScopedTempDir::file ( const std::string & basename)
inline

Build a path under the temp dir and register it for cleanup.

Definition at line 46 of file scoped_tempdir.h.

◆ keep()

Leave the directory on disk; cleanup is skipped at scope exit.

Definition at line 55 of file scoped_tempdir.h.

◆ operator=()

ScopedTempDir & provsql::ScopedTempDir::operator= ( const ScopedTempDir & )
delete

◆ path()

const std::string & provsql::ScopedTempDir::path ( ) const
inline

Definition at line 56 of file scoped_tempdir.h.

◆ track()

void provsql::ScopedTempDir::track ( const std::string & p)
inline

Also track a file we did not create through file() (e.g.

a helper tool's scratch output sitting in path_).

Definition at line 53 of file scoped_tempdir.h.

Member Data Documentation

◆ files_

std::vector<std::string> provsql::ScopedTempDir::files_
private

Definition at line 60 of file scoped_tempdir.h.

◆ keep_

bool provsql::ScopedTempDir::keep_ = false
private

Definition at line 61 of file scoped_tempdir.h.

◆ path_

std::string provsql::ScopedTempDir::path_
private

Definition at line 59 of file scoped_tempdir.h.


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