]> Chaos Git - corbenik/ctrulib.git/commitdiff
Bring back fsMakePath
authorfincs <fincs.alt1@gmail.com>
Sun, 15 Nov 2015 12:51:01 +0000 (13:51 +0100)
committerfincs <fincs.alt1@gmail.com>
Sun, 15 Nov 2015 12:51:01 +0000 (13:51 +0100)
libctru/include/3ds/services/fs.h
libctru/source/services/fs.c

index fc88c25638400599fd71821933099f6d0e86bf4c..87e1b75d7f613dffa8567fd51520c76cfe6b1f52 100644 (file)
@@ -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.
index e949b36c7011dc7282b226f6a7b1a4c6fc70e42d..8e18cbc547fb69d955a716b3626adc209f26e2fb 100644 (file)
@@ -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;