1
0
mirror of https://github.com/OpenRCT2/OpenRCT2 synced 2026-01-20 21:43:06 +01:00

start work on theme manager

This commit is contained in:
IntelOrca
2016-01-29 00:06:02 +00:00
parent de17eb7279
commit 0eb57e5fb5
3 changed files with 127 additions and 23 deletions

View File

@@ -5,6 +5,7 @@ extern "C"
#include "../util/util.h"
}
#include "Math.hpp"
#include "Memory.hpp"
#include "Path.hpp"
#include "String.hpp"
@@ -17,6 +18,29 @@ namespace Path
return safe_strcat_path(buffer, src, bufferSize);
}
utf8 * GetFileNameWithoutExtension(utf8 * buffer, size_t bufferSize, const utf8 * path)
{
const utf8 * lastDot = nullptr;
const utf8 * ch = path;
for (; ch != '\0'; ch++)
{
if (*ch == '.')
{
lastDot = ch;
}
}
if (lastDot == nullptr)
{
return String::Set(buffer, bufferSize, path);
}
size_t truncatedLength = Math::Min<size_t>(bufferSize - 1, lastDot - path);
Memory::Copy(buffer, path, truncatedLength);
buffer[truncatedLength] = '\0';
return buffer;
}
utf8 * GetAbsolute(utf8 *buffer, size_t bufferSize, const utf8 * relativePath)
{
#if __WINDOWS__