-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathutils.h
More file actions
28 lines (24 loc) · 664 Bytes
/
utils.h
File metadata and controls
28 lines (24 loc) · 664 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
#ifndef UTILS_H_
#define UTILS_H_
std::string get_extension(const std::string &path) {
size_t found = path.find_last_of(".");
if (found == std::string::npos) {
return "";
} else {
return path.substr(found + 1);
}
}
void split_path(const std::string &path, std::string &dir, std::string &file) {
size_t found = path.find_last_of("/");
if (found == std::string::npos) {
dir = ".";
file = path;
} else {
dir = path.substr(0, found);
file = path.substr(found + 1);
}
}
std::string join_path(const std::string &dir, const std::string &subdir) {
return dir + "/" + subdir;
}
#endif