Format string refactor

This commit is contained in:
Krzosa Karol
2025-11-27 23:13:28 +01:00
parent e9e8751981
commit d72485a137
24 changed files with 80 additions and 116 deletions

View File

@@ -482,7 +482,7 @@ API void Advance(FileIter *it) {
it->filename = ToString(it->allocator, (char16_t *)data->cFileName, WideLength((char16_t *)data->cFileName));
const char *is_dir = it->is_directory ? "/" : "";
const char *separator = it->path.data[it->path.len - 1] == '/' ? "" : "/";
it->relative_path = Format(it->allocator, "%.*s%s%.*s%s", FmtString(it->path), separator, FmtString(it->filename), is_dir);
it->relative_path = Format(it->allocator, "%S%s%S%s", it->path, separator, it->filename, is_dir);
it->absolute_path = GetAbsolutePath(it->allocator, it->relative_path);
it->is_valid = true;
@@ -504,7 +504,7 @@ API FileIter IterateFiles(Allocator alo, String path) {
it.allocator = alo;
it.path = path;
String modified_path = Format(it.allocator, "%.*s\\*", FmtString(path));
String modified_path = Format(it.allocator, "%S\\*", path);
String16 modified_path16 = ToString16(it.allocator, modified_path);
it.w32 = AllocType(it.allocator, Win32_FileIter);
@@ -672,7 +672,7 @@ static void Win32ReportError(String msg, String cmd) {
char *buff = (char *)lpMsgBuf;
size_t buffLen = strlen((const char *)buff);
if (buffLen > 0 && buff[buffLen - 1] == '\n') buff[buffLen - 1] = 0;
Error("%.*s: %.*s! %s", FmtString(msg), FmtString(cmd), (char *)lpMsgBuf);
Error("%S: %S! %s", msg, cmd, (char *)lpMsgBuf);
}
static void Win32CloseProcess(Process *process) {
@@ -715,7 +715,7 @@ API Process SpawnProcess(String command_line, String working_dir, String write_s
Win32Process *p = (Win32Process *)process.platform;
Scratch scratch;
command_line = Format(scratch, "/C %.*s", FmtString(command_line));
command_line = Format(scratch, "/C %S", command_line);
p->handle = INVALID_HANDLE_VALUE;
p->child_stdout_write = INVALID_HANDLE_VALUE;
@@ -759,6 +759,7 @@ API Process SpawnProcess(String command_line, String working_dir, String write_s
String16 cmd = ToString16(scratch, command_line);
char *env = NULL;
// TODO: FIX ARENA ALLOCATION USING PushSize, Prealloc maybe? Maybe we want a block arena
if (enviroment.len) {
Int size = GetSize(enviroment) + enviroment.len + 1;
env = (char *)PushSize(scratch, size);