LLVM 20.0.0git
Public Member Functions | List of all members
llvm::unittest::TempDir Class Reference

A RAII object that creates a temporary directory upon initialization and removes it upon destruction. More...

#include "llvm/Testing/Support/SupportHelpers.h"

Public Member Functions

 TempDir (StringRef Name, bool Unique=false)
 Creates a managed temporary directory.
 
 ~TempDir ()
 
 TempDir (const TempDir &)=delete
 
TempDiroperator= (const TempDir &)=delete
 
 TempDir (TempDir &&)=default
 
TempDiroperator= (TempDir &&)=default
 
StringRef path () const
 The path to the temporary directory.
 
const charc_str ()
 The null-terminated C string pointing to the path.
 
SmallString< 128 > path (StringRef component) const
 Creates a new path by appending the argument to the path of the managed directory using the native path separator.
 

Detailed Description

A RAII object that creates a temporary directory upon initialization and removes it upon destruction.

Definition at line 113 of file SupportHelpers.h.

Constructor & Destructor Documentation

◆ TempDir() [1/3]

llvm::unittest::TempDir::TempDir ( StringRef  Name,
bool  Unique = false 
)
inlineexplicit

Creates a managed temporary directory.

Parameters
NameThe name of the directory to create.
UniqueIf true, the directory will be created using llvm::sys::fs::createUniqueDirectory.

Definition at line 122 of file SupportHelpers.h.

References llvm::sys::fs::create_directory(), llvm::sys::fs::createUniqueDirectory(), Name, and llvm::sys::fs::real_path().

◆ ~TempDir()

llvm::unittest::TempDir::~TempDir ( )
inline

Definition at line 140 of file SupportHelpers.h.

References llvm::sys::fs::remove_directories().

◆ TempDir() [2/3]

llvm::unittest::TempDir::TempDir ( const TempDir )
delete

◆ TempDir() [3/3]

llvm::unittest::TempDir::TempDir ( TempDir &&  )
default

Member Function Documentation

◆ c_str()

const char * llvm::unittest::TempDir::c_str ( )
inline

The null-terminated C string pointing to the path.

Definition at line 156 of file SupportHelpers.h.

◆ operator=() [1/2]

TempDir & llvm::unittest::TempDir::operator= ( const TempDir )
delete

◆ operator=() [2/2]

TempDir & llvm::unittest::TempDir::operator= ( TempDir &&  )
default

◆ path() [1/2]

StringRef llvm::unittest::TempDir::path ( ) const
inline

The path to the temporary directory.

Definition at line 153 of file SupportHelpers.h.

◆ path() [2/2]

SmallString< 128 > llvm::unittest::TempDir::path ( StringRef  component) const
inline

Creates a new path by appending the argument to the path of the managed directory using the native path separator.

Definition at line 160 of file SupportHelpers.h.

References llvm::sys::path::append(), and llvm::sys::path::native.


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