stc
Loading...
Searching...
No Matches
Public Member Functions | Public Attributes | List of all members
stc::testutil::TestDirectory Struct Reference

#include <TestDirectory.hpp>

Public Member Functions

 TestDirectory (const std::filesystem::path &p, bool create=false)
 
 TestDirectory (const std::filesystem::path &p, bool create, bool dummyMode)
 
 ~TestDirectory ()
 
void checkCompatiblePath (const std::filesystem::path &p)
 
void deleteFolder ()
 

Public Attributes

std::filesystem::path folder
 
bool dummyMode = false
 

Detailed Description

Test utility for RAII ownership of a folder.

The folder, if it exists at the time of initialization, is deleted. It's also deleted at the end of the test when this class is destroyed.

Note
This class is incompatible with symlinks.
There are some protections in place to avoid common mistakes that decay to deleting standard UNIX folders, or the root folder. You cannot take ownership of anything under /usr, /bin, /share, /dev, /etc, /proc, or /boot. This is just a list of the most risky folders, though there are others that may be dangerous. Make sure to validate any generated paths you create BEFORE passing them to this class even with these protections in place.

Constructor & Destructor Documentation

◆ TestDirectory() [1/2]

stc::testutil::TestDirectory::TestDirectory ( const std::filesystem::path &  p,
bool  create = false 
)
inline

◆ TestDirectory() [2/2]

stc::testutil::TestDirectory::TestDirectory ( const std::filesystem::path &  p,
bool  create,
bool  dummyMode 
)
inline

◆ ~TestDirectory()

stc::testutil::TestDirectory::~TestDirectory ( )
inline

Member Function Documentation

◆ checkCompatiblePath()

void stc::testutil::TestDirectory::checkCompatiblePath ( const std::filesystem::path &  p)
inline

◆ deleteFolder()

void stc::testutil::TestDirectory::deleteFolder ( )
inline

Member Data Documentation

◆ dummyMode

bool stc::testutil::TestDirectory::dummyMode = false

◆ folder

std::filesystem::path stc::testutil::TestDirectory::folder

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