MySQL 8.0.39
Source Code Documentation
path.h
Go to the documentation of this file.
1/*
2 Copyright (c) 2012, 2024, Oracle and/or its affiliates.
3
4 This program is free software; you can redistribute it and/or modify
5 it under the terms of the GNU General Public License, version 2.0,
6 as published by the Free Software Foundation.
7
8 This program is designed to work with certain software (including
9 but not limited to OpenSSL) that is licensed under separate terms,
10 as designated in a particular file or component or in included license
11 documentation. The authors of MySQL hereby grant you an additional
12 permission to link the program and your derivative works with the
13 separately licensed software that they have either included with
14 the program or referenced in the documentation.
15
16 This program is distributed in the hope that it will be useful,
17 but WITHOUT ANY WARRANTY; without even the implied warranty of
18 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 GNU General Public License, version 2.0, for more details.
20
21 You should have received a copy of the GNU General Public License
22 along with this program; if not, write to the Free Software
23 Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
24*/
25#ifndef PATH_UTIL_INCLUDED
26#define PATH_UTIL_INCLUDED
27#include <ostream>
28#include <string>
29
30/**
31 A helper class for handling file paths. The class can handle the memory
32 on its own or it can wrap an external string.
33 @note This is a rather trivial wrapper which doesn't handle malformed paths
34 or filenames very well.
35 @see unittest/gunit/path-t.cc
36
37*/
38class Path {
39 public:
41
42 Path(const std::string &s);
43
44 Path(const Path &p);
45
46 bool path_getcwd();
47
48 void trim();
49
50 void parent_directory(Path *out);
51
52 Path &up();
53
54 Path &append(const std::string &path);
55
56 Path &filename_append(const std::string &ext);
57
58 void path(const std::string &p);
59
60 void filename(const std::string &f);
61
62 void path(const Path &p);
63
64 void filename(const Path &p);
65
66 bool qpath(const std::string &qp);
67
68 bool normalize_path();
69
70 bool is_qualified_path();
71
72 bool exists();
73
74 const std::string to_str();
75
76 bool empty();
77#ifndef _WIN32
78 void get_homedir();
79#endif
80
81 friend std::ostream &operator<<(std::ostream &op, const Path &p);
82
83 private:
84 std::string m_path;
85 std::string m_filename;
86};
87
88std::ostream &operator<<(std::ostream &op, const Path &p);
89
90#endif
A helper class for handling file paths.
Definition: path.h:38
bool normalize_path()
Definition: path.cc:125
const std::string to_str()
Definition: path.cc:161
Path & append(const std::string &path)
Definition: path.cc:85
friend std::ostream & operator<<(std::ostream &op, const Path &p)
Definition: path.cc:195
void path(const std::string &p)
Definition: path.cc:98
std::string m_filename
Definition: path.h:85
void get_homedir()
Definition: path.cc:184
void parent_directory(Path *out)
Definition: path.cc:68
Path & up()
Definition: path.cc:76
void filename(const std::string &f)
Definition: path.cc:104
bool qpath(const std::string &qp)
Definition: path.cc:110
bool is_qualified_path()
Definition: path.cc:143
bool path_getcwd()
Definition: path.cc:49
void trim()
Definition: path.cc:58
std::string m_path
Definition: path.h:84
Path & filename_append(const std::string &ext)
Definition: path.cc:92
bool exists()
Definition: path.cc:145
bool empty()
Definition: path.cc:170
const char * p
Definition: ctype-mb.cc:1237
Json_data_extension ext
Definition: backend.cc:51
std::ostream & operator<<(std::ostream &op, const Path &p)
Definition: path.cc:195