C++ conversion (#80)

Converted project to C++
This commit is contained in:
Ken Van Hoeylandt
2024-11-22 20:26:08 +01:00
committed by GitHub
parent 6d80144e12
commit 85e26636a3
488 changed files with 6017 additions and 39466 deletions
+30
View File
@@ -0,0 +1,30 @@
#include "StringUtils.h"
#include <cstring>
namespace tt {
int string_find_last_index(const char* text, size_t from_index, char find) {
for (size_t i = from_index; i >= 0; i--) {
if (text[i] == find) {
return (int)i;
}
}
return -1;
}
bool string_get_path_parent(const char* path, char* output) {
int index = string_find_last_index(path, strlen(path) - 1, '/');
if (index == -1) {
return false;
} else if (index == 0) {
output[0] = '/';
output[1] = 0x00;
return true;
} else {
memcpy(output, path, index);
output[index] = 0x00;
return true;
}
}
} // namespace