26#ifndef MYSQL_HARNESS_FILESYSTEM_INCLUDED
27#define MYSQL_HARNESS_FILESYSTEM_INCLUDED
29#include "harness_export.h"
36#include <system_error>
112 friend HARNESS_EXPORT std::ostream &
operator<<(std::ostream &out,
132 const std::string &extension);
156 FileType
type(
bool refresh =
false)
const;
161 bool is_directory()
const;
166 bool is_regular()
const;
177 bool is_absolute()
const;
190 bool is_readable()
const;
230 void append(
const Path &other);
248 Path real_path()
const;
259 const char *
c_str()
const {
return path_.c_str(); }
266 const std::string &
str() const noexcept {
return path_; }
273 bool is_set() const noexcept {
return (type_ != FileType::EMPTY_PATH); }
291 operator bool() const noexcept {
return is_set(); }
294 void validate_non_empty_path()
const;
333 const std::string &pattern = std::string());
352#if !defined(_MSC_VER) || (_MSC_VER >= 1900)
359 Path operator*()
const;
428 DirectoryIterator cbegin()
const;
435 DirectoryIterator
end();
444 DirectoryIterator cend()
const;
452 bool is_empty()
const;
462 std::vector<Path> list_recursive()
const;
467 DirectoryIterator glob(
const std::string &glob);
486 const std::string &
dir)
noexcept;
498 const std::string &
path)
noexcept;
510 const std::string &
dir)
noexcept;
606 const bool read_only_for_local_service =
true);
Definition: filesystem-posix.cc:125
Directory iterator for iterating over directory entries.
Definition: filesystem.h:322
const Path path_
Path to the root of the directory.
Definition: filesystem.h:376
std::input_iterator_tag iterator_category
Definition: filesystem.h:327
Path operator->()
Definition: filesystem.h:361
DirectoryIterator(const DirectoryIterator &)
bool operator==(const DirectoryIterator &other) const
Definition: filesystem.h:367
~DirectoryIterator()
Destructor.
std::shared_ptr< State > state_
Definition: filesystem.h:394
DirectoryIterator(DirectoryIterator &&)
std::ptrdiff_t difference_type
Definition: filesystem.h:328
std::string pattern_
Pattern that matches entries iterated over.
Definition: filesystem.h:381
Class representing a directory in a file system.
Definition: filesystem.h:315
DirectoryIterator end() const
Definition: filesystem.h:437
DirectoryIterator begin() const
Definition: filesystem.h:421
Directory(const Directory &)=default
Directory & operator=(const Directory &)=default
Directory(const std::string &path)
Construct a directory instance.
Definition: filesystem.h:404
Class representing a path in a file system.
Definition: filesystem.h:63
std::string path_
Definition: filesystem.h:296
const char * c_str() const
Get a C-string representation to the path.
Definition: filesystem.h:259
FileType type_
Definition: filesystem.h:297
bool is_set() const noexcept
Test if path is set.
Definition: filesystem.h:273
bool operator!=(const Path &rhs) const
Definition: filesystem.h:135
FileType
Enum used to identify file types.
Definition: filesystem.h:74
static const char *const root_directory
Root directory string.
Definition: filesystem.h:289
static const char *const directory_separator
Directory separator string.
Definition: filesystem.h:281
const std::string & str() const noexcept
Get a string representation of the path.
Definition: filesystem.h:266
friend std::ostream & operator<<(std::ostream &out, const Path &path)
Definition: filesystem.h:64
Path(const char *path)
Definition: filesystem.h:126
Definition: expected.h:944
HARNESS_EXPORT stdx::expected< void, std::error_code > delete_file(const std::string &path) noexcept
Removes a file.
Definition: filesystem-posix.cc:319
HARNESS_EXPORT stdx::expected< void, std::error_code > delete_dir(const std::string &dir) noexcept
Removes a directory.
Definition: filesystem-posix.cc:309
HARNESS_EXPORT std::string get_tmp_dir(const std::string &name="router")
Creates a temporary directory with partially-random name and returns its path.
Definition: filesystem-posix.cc:329
HARNESS_EXPORT stdx::expected< void, std::error_code > delete_dir_recursive(const std::string &dir) noexcept
Removes directory and all its contents.
Definition: filesystem.cc:247
bool operator!=(const my_thread_handle &a, const my_thread_handle &b)
Definition: my_thread.h:158
bool operator==(const my_thread_handle &a, const my_thread_handle &b)
Definition: my_thread.h:151
static char * path
Definition: mysqldump.cc:137
std::string dir
Double write files location.
Definition: buf0dblwr.cc:77
std::string file_name(Log_file_id file_id)
Provides name of the log file with the given file id, e.g.
Definition: log0pre_8_0_30.cc:94
std::string dirname(const std::string &path)
Definition: utilities.cc:38
std::string basename(const std::string &path)
Definition: utilities.cc:46
void HARNESS_EXPORT make_file_readonly(const std::string &file_name)
Changes file access permissions to be read only.
Definition: filesystem-posix.cc:374
HARNESS_EXPORT std::string get_tests_data_dir(const std::string &runtime_dir)
Definition: filesystem.cc:286
HARNESS_EXPORT int mkdir(const std::string &dir, perm_mode mode, bool recursive=false)
Creates a directory *.
Definition: filesystem.cc:331
void HARNESS_EXPORT check_file_access_rights(const std::string &file_name)
Verifies access permissions of a file.
Definition: filesystem.cc:339
void HARNESS_EXPORT make_file_private(const std::string &file_name, const bool read_only_for_local_service=true)
Changes file access permissions to be accessible only by a limited set of users.
Definition: filesystem-posix.cc:363
HARNESS_EXPORT std::string get_plugin_dir(const std::string &runtime_dir)
Definition: filesystem.cc:268
void HARNESS_EXPORT make_file_public(const std::string &file_name)
Changes file access permissions to be fully accessible by all users.
Definition: filesystem-posix.cc:354
std::string join(Container cont, const std::string &delim)
join elements of an container into a string separated by a delimiter.
Definition: string.h:151
mode_t perm_mode
Definition: filesystem.h:542
void make_file_readable_for_everyone(const std::string &file_name)
Definition: filesystem-windows.cc:459
HARNESS_EXPORT const perm_mode kStrictDirectoryPerm
Definition: filesystem-posix.cc:62
std::ostream & operator<<(std::ostream &out, Path::FileType type)
Definition: filesystem.cc:168
constexpr bool operator<(const address_v4 &a, const address_v4 &b) noexcept
Definition: internet.h:166
Cursor end()
A past-the-end Cursor.
Definition: rules_table_service.cc:192
Definition: gcs_xcom_synode.h:64
mode
Definition: file_handle.h:60
static int exists(node_address *name, node_list const *nodes, u_int with_uid)
Definition: node_list.cc:106
bool_t is_set(node_set set, node_no i)
Definition: node_set.cc:230
required string type
Definition: replication_group_member_actions.proto:34
Ssl_acceptor_context_property_type & operator++(Ssl_acceptor_context_property_type &property_type)
Increment operator for Ssl_acceptor_context_type Used by iterator.
Definition: ssl_acceptor_context_data.cc:114
case opt name
Definition: sslopt-case.h:33