From 75575b4a41d693d3cf5a7b903bf1c970c980ddd4 Mon Sep 17 00:00:00 2001 From: archshift Date: Wed, 10 Dec 2014 22:16:52 -0800 Subject: [PATCH] Added common folder, with a new string helper file. --- Makefile | 2 +- source/{ => common}/scope_exit.h | 0 source/common/string_funcs.cpp | 25 +++++++++++++++++++++++++ source/common/string_funcs.h | 9 +++++++++ source/tests/fs/fs_sdmc.cpp | 2 +- 5 files changed, 36 insertions(+), 2 deletions(-) rename source/{ => common}/scope_exit.h (100%) create mode 100644 source/common/string_funcs.cpp create mode 100644 source/common/string_funcs.h diff --git a/Makefile b/Makefile index cfd75dd..9cc97b3 100644 --- a/Makefile +++ b/Makefile @@ -19,7 +19,7 @@ include $(DEVKITARM)/3ds_rules #--------------------------------------------------------------------------------- export TARGET := $(shell basename $(CURDIR)) BUILD := build -SOURCES := source source/tests source/tests/fs source/tests/cpu +SOURCES := source source/common source/tests source/tests/fs source/tests/cpu DATA := data INCLUDES := source #include diff --git a/source/scope_exit.h b/source/common/scope_exit.h similarity index 100% rename from source/scope_exit.h rename to source/common/scope_exit.h diff --git a/source/common/string_funcs.cpp b/source/common/string_funcs.cpp new file mode 100644 index 0000000..71fc65e --- /dev/null +++ b/source/common/string_funcs.cpp @@ -0,0 +1,25 @@ +#include "string_funcs.h" + +#include +#include +#include +#include + +namespace Common { + +std::string FormatString(const char* format, ...) +{ + va_list arguments; + char *va_str; + + va_start(arguments, format); + vasprintf(&va_str, format, arguments); + va_end(arguments); + + std::string out_str(va_str); + free(va_str); + + return out_str; +} + +} diff --git a/source/common/string_funcs.h b/source/common/string_funcs.h new file mode 100644 index 0000000..434b029 --- /dev/null +++ b/source/common/string_funcs.h @@ -0,0 +1,9 @@ +#pragma once + +#include + +namespace Common { + +std::string FormatString(const char* format, ...); + +} diff --git a/source/tests/fs/fs_sdmc.cpp b/source/tests/fs/fs_sdmc.cpp index 7dc6146..614b7f4 100644 --- a/source/tests/fs/fs_sdmc.cpp +++ b/source/tests/fs/fs_sdmc.cpp @@ -2,7 +2,7 @@ #include #include <3ds.h> -#include "scope_exit.h" +#include "common/scope_exit.h" #include "tests/test.h" #include "tests/fs/fs_sdmc.h"