diff --git a/source/draw.c b/source/draw.c
index a6a99f5..14b8b0e 100644
--- a/source/draw.c
+++ b/source/draw.c
@@ -26,20 +26,12 @@
*/
#include "draw.h"
+#include "strings.h"
#include "screen.h"
#include "utils.h"
#include "fs.h"
#include "font.h"
-static inline int strlen(const char *string)
-{
- char *stringEnd = (char *)string;
-
- while(*stringEnd) stringEnd++;
-
- return stringEnd - string;
-}
-
bool loadSplash(void)
{
//Don't delay boot nor init the screens if no splash image is on the SD
diff --git a/source/fs.c b/source/fs.c
index f428bbe..67890de 100644
--- a/source/fs.c
+++ b/source/fs.c
@@ -22,6 +22,7 @@
#include "fs.h"
#include "memory.h"
+#include "strings.h"
#include "cache.h"
#include "screen.h"
#include "fatfs/ff.h"
@@ -127,8 +128,8 @@ void loadPayload(u32 pressed)
memcpy(loaderAddress, loader, loader_size);
- path[14] = '/';
- memcpy(&path[15], info.altname, 13);
+ concatenateStrings(path, "/");
+ concatenateStrings(path, info.altname);
loaderAddress[1] = fileRead((void *)0x24F00000, path);
@@ -147,7 +148,7 @@ u32 firmRead(void *dest, u32 firmType)
{ "00000003", "20000003" }};
char path[48] = "1:/title/00040138/00000000/content";
- memcpy(&path[18], firmFolders[firmType][isN3DS ? 1 : 0], 8);
+ concatenateStrings(path, firmFolders[firmType][isN3DS ? 1 : 0]);
DIR dir;
FILINFO info;
@@ -177,7 +178,7 @@ u32 firmRead(void *dest, u32 firmType)
f_closedir(&dir);
//Complete the string with the .app name
- memcpy(&path[34], "/00000000.app", 14);
+ concatenateStrings(path, "/00000000.app");
//Last digit of the .app
u32 i = 42;
diff --git a/source/strings.c b/source/strings.c
new file mode 100644
index 0000000..adaa712
--- /dev/null
+++ b/source/strings.c
@@ -0,0 +1,41 @@
+/*
+* This file is part of Luma3DS
+* Copyright (C) 2016 Aurora Wright, TuxSH
+*
+* This program is free software: you can redistribute it and/or modify
+* it under the terms of the GNU General Public License as published by
+* the Free Software Foundation, either version 3 of the License, or
+* (at your option) any later version.
+*
+* This program is distributed in the hope that it will be useful,
+* but WITHOUT ANY WARRANTY; without even the implied warranty of
+* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+* GNU General Public License for more details.
+*
+* You should have received a copy of the GNU General Public License
+* along with this program. If not, see .
+*
+* Additional Terms 7.b of GPLv3 applies to this file: Requiring preservation of specified
+* reasonable legal notices or author attributions in that material or in the Appropriate Legal
+* Notices displayed by works containing it.
+*/
+
+#include "strings.h"
+#include "memory.h"
+
+int strlen(const char *string)
+{
+ char *stringEnd = (char *)string;
+
+ while(*stringEnd) stringEnd++;
+
+ return stringEnd - string;
+}
+
+void concatenateStrings(char *destination, const char *source)
+{
+ int i = strlen(source),
+ j = strlen(destination);
+
+ memcpy(&destination[j], source, i + 1);
+}
\ No newline at end of file
diff --git a/source/strings.h b/source/strings.h
new file mode 100644
index 0000000..f6b035f
--- /dev/null
+++ b/source/strings.h
@@ -0,0 +1,28 @@
+/*
+* This file is part of Luma3DS
+* Copyright (C) 2016 Aurora Wright, TuxSH
+*
+* This program is free software: you can redistribute it and/or modify
+* it under the terms of the GNU General Public License as published by
+* the Free Software Foundation, either version 3 of the License, or
+* (at your option) any later version.
+*
+* This program is distributed in the hope that it will be useful,
+* but WITHOUT ANY WARRANTY; without even the implied warranty of
+* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+* GNU General Public License for more details.
+*
+* You should have received a copy of the GNU General Public License
+* along with this program. If not, see .
+*
+* Additional Terms 7.b of GPLv3 applies to this file: Requiring preservation of specified
+* reasonable legal notices or author attributions in that material or in the Appropriate Legal
+* Notices displayed by works containing it.
+*/
+
+#pragma once
+
+#include "types.h"
+
+int strlen(const char *string);
+void concatenateStrings(char *destination, const char *source);
\ No newline at end of file