Calling DllMain, fixing ref count, and fixing module search.

This commit is contained in:
Ben Vanik
2015-05-09 00:56:42 -07:00
parent 0c646f4bc2
commit 23eb343484
11 changed files with 168 additions and 66 deletions

View File

@@ -68,6 +68,20 @@ std::vector<std::string> split_path(const std::string& path) {
return parts;
}
std::string join_paths(const std::string& left, const std::string& right,
char sep) {
if (!left.size()) {
return right;
} else if (!right.size()) {
return left;
}
if (left[left.size() - 1] == sep) {
return left + right;
} else {
return left + sep + right;
}
}
std::wstring join_paths(const std::wstring& left, const std::wstring& right,
wchar_t sep) {
if (!left.size()) {
@@ -166,4 +180,20 @@ std::wstring find_name_from_path(const std::wstring& path) {
return name;
}
std::string find_base_path(const std::string& path) {
auto last_slash = path.find_last_of('\\');
if (last_slash == std::string::npos) {
return path;
} else if (last_slash == path.length() - 1) {
auto prev_slash = path.find_last_of('\\', last_slash - 1);
if (prev_slash == std::string::npos) {
return "";
} else {
return path.substr(0, prev_slash + 1);
}
} else {
return path.substr(0, last_slash + 1);
}
}
} // namespace xe

View File

@@ -32,6 +32,8 @@ std::wstring to_absolute_path(const std::wstring& path);
std::vector<std::string> split_path(const std::string& path);
// Joins two path segments with the given separator.
std::string join_paths(const std::string& left, const std::string& right,
char sep = xe::path_separator);
std::wstring join_paths(const std::wstring& left, const std::wstring& right,
wchar_t sep = xe::path_separator);
@@ -42,10 +44,13 @@ std::wstring fix_path_separators(const std::wstring& source,
std::string fix_path_separators(const std::string& source,
char new_sep = xe::path_separator);
// Find the top directory name or filename from a path
// Find the top directory name or filename from a path.
std::string find_name_from_path(const std::string& path);
std::wstring find_name_from_path(const std::wstring& path);
// Get parent path of the given directory or filename.
std::string find_base_path(const std::string& path);
} // namespace xe
#endif // XENIA_BASE_STRING_H_