android: add logging

This commit is contained in:
BreadFish64 2019-02-15 20:37:36 -06:00
parent 9848610ea2
commit f767b5fdef
10 changed files with 160 additions and 30 deletions

View file

@ -7,6 +7,7 @@
#include <codecvt>
#include <cstdlib>
#include <locale>
#include <regex>
#include <sstream>
#include "common/common_paths.h"
#include "common/logging/log.h"
@ -210,25 +211,17 @@ std::string StringFromFixedZeroTerminatedBuffer(const char* buffer, std::size_t
return std::string(buffer, len);
}
const char* TrimSourcePath(const char* path, const char* root) {
const char* p = path;
while (*p != '\0') {
const char* next_slash = p;
while (*next_slash != '\0' && *next_slash != '/' && *next_slash != '\\') {
++next_slash;
}
bool is_src = Common::ComparePartialString(p, next_slash, root);
p = next_slash;
if (*p != '\0') {
++p;
}
if (is_src) {
path = p;
}
std::string TrimSourcePath(const std::string& file_path, const std::vector<std::string>& roots) {
// match from beginning of path to dir sep
std::string regex_src = R"(.*([\/\\]|^)()";
// plus the last occurrence of any root
for (auto root = roots.begin(); root < roots.end() - 1; ++root) {
regex_src += '(' + *root + ")|";
}
return path;
regex_src += '(' + roots.back() + ')';
// plus dir sep
regex_src += R"()[\/\\])";
std::regex regex(regex_src);
return std::regex_replace(file_path, regex, "");
}
} // namespace Common