27Filename::split(
const string& full_name,
string& directory,
28 string& name,
string& extension)
const
31 if (!full_name.empty()) {
33 bool dir_present =
false;
35 size_t last_slash = full_name.find_last_of(
'/');
36 if (last_slash != string::npos) {
40 directory = full_name.substr(0, last_slash + 1);
41 if (last_slash == full_name.size()) {
53 size_t last_dot = full_name.find_last_of(
'.');
54 if ((last_dot == string::npos) ||
55 (dir_present && (last_dot < last_slash))) {
61 name = full_name.substr(last_slash + 1);
70 if ((last_dot - last_slash) > 1) {
71 name = full_name.substr(last_slash + 1, last_dot - last_slash - 1);
82 string def_directory(
"");
84 string def_extension(
"");
93 split(copy_defname, def_directory, def_name, def_extension);
97 (directory_.empty() ? def_directory : directory_) +
98 (name_.empty() ? def_name : name_) +
99 (extension_.empty() ? def_extension : extension_);
108 string name_directory(
"");
109 string name_name(
"");
110 string name_extension(
"");
119 split(copy_name, name_directory, name_name, name_extension);
123 (name_directory.empty() ? directory_ : name_directory) +
124 (name_name.empty() ? name_ : name_name) +
125 (name_extension.empty() ? extension_ : name_extension);
136 if (sep == std::string::npos || sep <
directory.size() - 1) {
141 std::string full_name =
directory + name_ + extension_;
144 full_name_.swap(full_name);
std::string extension() const
std::string expandWithDefault(const std::string &defname) const
Expand Name with Default.
std::string directory() const
void setDirectory(const std::string &new_directory)
Set directory for the file.
std::string useAsDefault(const std::string &name) const
Use as Default and Substitute into String.
void normalizeSlash(std::string &name)
Normalize Backslash.
string trim(const string &instring)
Trim Leading and Trailing Spaces.
Defines the logger used by the top-level component of kea-dhcp-ddns.