MySQL 8.0.30
Source Code Documentation
path.h
Go to the documentation of this file.
1/*
2 Copyright (c) 2012, 2022, 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 also distributed 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 included with MySQL.
14
15 This program is distributed in the hope that it will be useful,
16 but WITHOUT ANY WARRANTY; without even the implied warranty of
17 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 GNU General Public License, version 2.0, for more details.
19
20 You should have received a copy of the GNU General Public License
21 along with this program; if not, write to the Free Software
22 Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
23*/
24#ifndef PATH_UTIL_INCLUDED
25#define PATH_UTIL_INCLUDED
26#include <ostream>
27#include <string>
28
29/**
30 A helper class for handling file paths. The class can handle the memory
31 on its own or it can wrap an external string.
32 @note This is a rather trivial wrapper which doesn't handle malformed paths
33 or filenames very well.
34 @see unittest/gunit/path-t.cc
35
36*/
37class Path {
38 public:
40
41 Path(const std::string &s);
42
43 Path(const Path &p);
44
45 bool path_getcwd();
46
47 void trim();
48
49 void parent_directory(Path *out);
50
51 Path &up();
52
53 Path &append(const std::string &path);
54
55 Path &filename_append(const std::string &ext);
56
57 void path(const std::string &p);
58
59 void filename(const std::string &f);
60
61 void path(const Path &p);
62
63 void filename(const Path &p);
64
65 bool qpath(const std::string &qp);
66
67 bool normalize_path();
68
69 bool is_qualified_path();
70
71 bool exists();
72
73 const std::string to_str();
74
75 bool empty();
76#ifndef _WIN32
77 void get_homedir();
78#endif
79
80 friend std::ostream &operator<<(std::ostream &op, const Path &p);
81
82 private:
83 std::string m_path;
84 std::string m_filename;
85};
86
87std::ostream &operator<<(std::ostream &op, const Path &p);
88
89#endif
A helper class for handling file paths.
Definition: path.h:37
bool normalize_path()
Definition: path.cc:124
const std::string to_str()
Definition: path.cc:160
Path & append(const std::string &path)
Definition: path.cc:84
friend std::ostream & operator<<(std::ostream &op, const Path &p)
Definition: path.cc:194
void path(const std::string &p)
Definition: path.cc:97
std::string m_filename
Definition: path.h:84
void get_homedir()
Definition: path.cc:183
void parent_directory(Path *out)
Definition: path.cc:67
Path & up()
Definition: path.cc:75
void filename(const std::string &f)
Definition: path.cc:103
bool qpath(const std::string &qp)
Definition: path.cc:109
bool is_qualified_path()
Definition: path.cc:142
bool path_getcwd()
Definition: path.cc:48
void trim()
Definition: path.cc:57
std::string m_path
Definition: path.h:83
Path & filename_append(const std::string &ext)
Definition: path.cc:91
bool exists()
Definition: path.cc:144
bool empty()
Definition: path.cc:169
const char * p
Definition: ctype-mb.cc:1236
Json_data_extension ext
Definition: backend.cc:50
std::ostream & operator<<(std::ostream &op, const Path &p)
Definition: path.cc:194