From b96697f7a4d2bce4f34e06fd5b977ea92be75a7c Mon Sep 17 00:00:00 2001 From: fincs Date: Sun, 15 Nov 2015 13:51:01 +0100 Subject: [PATCH] Bring back fsMakePath --- libctru/include/3ds/services/fs.h | 10 +++++++++- libctru/source/services/fs.c | 24 ++++++++++++++++++++++++ 2 files changed, 33 insertions(+), 1 deletion(-) diff --git a/libctru/include/3ds/services/fs.h b/libctru/include/3ds/services/fs.h index fc88c25..87e1b75 100644 --- a/libctru/include/3ds/services/fs.h +++ b/libctru/include/3ds/services/fs.h @@ -221,7 +221,7 @@ typedef struct { FS_PathType type; ///< FS path type. u32 size; ///< FS path size. - const u8* data; ///< Pointer to FS path data. + const void* data; ///< Pointer to FS path data. } FS_Path; /// FS archive. @@ -238,6 +238,14 @@ Result fsInit(void); /// Exits FS. void fsExit(void); +/** + * Creates an FS_Path instance. + * @param type Type of path. + * @param path Path to use. + * @return The created FS_Path instance. + */ +FS_Path fsMakePath(FS_PathType type, const void* path); + /** * @brief Gets the current FS session handle. * @return The current FS session handle. diff --git a/libctru/source/services/fs.c b/libctru/source/services/fs.c index e949b36..8e18cbc 100644 --- a/libctru/source/services/fs.c +++ b/libctru/source/services/fs.c @@ -36,6 +36,30 @@ void fsExit(void) svcCloseHandle(fsuHandle); } +FS_Path fsMakePath(FS_PathType type, const void* path) +{ + FS_Path p = { type, 0, path }; + switch (type) + { + case PATH_ASCII: + p.size = strlen((const char*)path)+1; + break; + case PATH_UTF16: + { + const u16* str = (const u16*)path; + while (*str++) p.size++; + p.size++; + break; + } + case PATH_EMPTY: + p.size = 1; + p.data = ""; + default: + break; + } + return p; +} + Handle* fsGetSessionHandle(void) { return &fsuHandle;