MySQL 8.3.0
Source Code Documentation
Platform-independent file system operations

This module contain platform-independent file system operations. More...

Classes

class  mysql_harness::Path
 Class representing a path in a file system. More...
 
class  mysql_harness::Directory
 Class representing a directory in a file system. More...
 

Functions

HARNESS_EXPORT stdx::expected< void, std::error_code > mysql_harness::delete_dir (const std::string &dir) noexcept
 Removes a directory. More...
 
HARNESS_EXPORT stdx::expected< void, std::error_code > mysql_harness::delete_file (const std::string &path) noexcept
 Removes a file. More...
 
HARNESS_EXPORT stdx::expected< void, std::error_code > mysql_harness::delete_dir_recursive (const std::string &dir) noexcept
 Removes directory and all its contents. More...
 
HARNESS_EXPORT std::string mysql_harness::get_tmp_dir (const std::string &name="router")
 Creates a temporary directory with partially-random name and returns its path. More...
 

Detailed Description

This module contain platform-independent file system operations.

Function Documentation

◆ delete_dir()

stdx::expected< void, std::error_code > mysql_harness::delete_dir ( const std::string &  dir)
noexcept

Removes a directory.

Parameters
dirpath of the directory to be removed; this directory must be empty
Returns
void on success, error_code on failure

◆ delete_dir_recursive()

stdx::expected< void, std::error_code > mysql_harness::delete_dir_recursive ( const std::string &  dir)
noexcept

Removes directory and all its contents.

Parameters
dirpath of the directory to be removed
Returns
void on success, error_code on failure

◆ delete_file()

stdx::expected< void, std::error_code > mysql_harness::delete_file ( const std::string &  path)
noexcept

Removes a file.

Parameters
pathof the file to be removed
Returns
void on success, error_code on failure

◆ get_tmp_dir()

std::string mysql_harness::get_tmp_dir ( const std::string &  name = "router")

Creates a temporary directory with partially-random name and returns its path.

Creates a directory with a name of form {prefix}-{6 random alphanumerals}. For example, a possible directory name created by a call to get_tmp_dir("foo") might be: foo-3f9x0z

Such directory is usually meant to be used as a temporary directory (thus the "_tmp_" in the name of this function).

Parameters
namename to be used as a directory name prefix
Returns
path to the created directory
Exceptions
std::runtime_errorif operation failed