Code cleanup

This commit is contained in:
Maschell
2024-11-27 20:44:36 +01:00
parent 5893ac2f18
commit 6f7afe387e
95 changed files with 1517 additions and 1212 deletions

View File

@@ -30,14 +30,12 @@
#include <coreinit/debug.h>
#include <memory>
#include <string>
#include <vector>
#include <wut_types.h>
template<typename... Args>
std::string string_format(std::string_view format, Args... args) {
int size_s = std::snprintf(nullptr, 0, format.data(), args...) + 1; // Extra space for '\0'
auto size = static_cast<size_t>(size_s);
auto buf = make_unique_nothrow<char[]>(size);
std::string string_format(const std::string_view format, Args... args) {
const int size_s = std::snprintf(nullptr, 0, format.data(), args...) + 1; // Extra space for '\0'
const auto size = static_cast<size_t>(size_s);
const auto buf = make_unique_nothrow<char[]>(size);
if (!buf) {
DEBUG_FUNCTION_LINE_ERR("string_format failed, not enough memory");
OSFatal("string_format failed, not enough memory");
@@ -53,33 +51,7 @@ public:
static int32_t strtokcmp(const char *string, const char *compare, const char *separator);
static const char *FullpathToFilename(const char *path) {
if (!path)
return path;
static const char *FullpathToFilename(const char *path);
const char *ptr = path;
const char *Filename = ptr;
while (*ptr != '\0') {
if (ptr[0] == '/' && ptr[1] != '\0')
Filename = ptr + 1;
++ptr;
}
return Filename;
}
static void RemoveDoubleSlashs(std::string &str) {
uint32_t length = str.size();
//! clear path of double slashes
for (uint32_t i = 1; i < length; ++i) {
if (str[i - 1] == '/' && str[i] == '/') {
str.erase(i, 1);
i--;
length--;
}
}
}
static void RemoveDoubleSlashes(std::string &str);
};