LLVM  14.0.0git
Public Member Functions | List of all members
llvm::unittest::TempFile Class Reference

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

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

Public Member Functions

 TempFile (StringRef Name, StringRef Suffix="", StringRef Contents="", bool Unique=false)
 Creates a managed file. More...
 
 ~TempFile ()
 
StringRef path () const
 The path to the file. More...
 

Detailed Description

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

Definition at line 203 of file SupportHelpers.h.

Constructor & Destructor Documentation

◆ TempFile()

llvm::unittest::TempFile::TempFile ( StringRef  Name,
StringRef  Suffix = "",
StringRef  Contents = "",
bool  Unique = false 
)
inline

Creates a managed file.

Parameters
NameThe name of the file to create.
ContentsThe string to write to the file.
UniqueIf true, the file will be created using llvm::sys::fs::createTemporaryFile.

Definition at line 213 of file SupportHelpers.h.

References llvm::SmallString< InternalLen >::append(), llvm::SmallVectorImpl< T >::clear(), llvm::sys::fs::createTemporaryFile(), llvm::raw_fd_ostream::error(), llvm::raw_ostream::flush(), and llvm::sys::fs::openFileForWrite().

◆ ~TempFile()

llvm::unittest::TempFile::~TempFile ( )
inline

Member Function Documentation

◆ path()

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

The path to the file.

Definition at line 242 of file SupportHelpers.h.


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