Bring back fsMakePath

This commit is contained in:
fincs 2015-11-15 13:51:01 +01:00
parent 083e89628e
commit b96697f7a4
2 changed files with 33 additions and 1 deletions

View File

@ -221,7 +221,7 @@ typedef struct
{ {
FS_PathType type; ///< FS path type. FS_PathType type; ///< FS path type.
u32 size; ///< FS path size. u32 size; ///< FS path size.
const u8* data; ///< Pointer to FS path data. const void* data; ///< Pointer to FS path data.
} FS_Path; } FS_Path;
/// FS archive. /// FS archive.
@ -238,6 +238,14 @@ Result fsInit(void);
/// Exits FS. /// Exits FS.
void fsExit(void); 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. * @brief Gets the current FS session handle.
* @return The current FS session handle. * @return The current FS session handle.

View File

@ -36,6 +36,30 @@ void fsExit(void)
svcCloseHandle(fsuHandle); 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) Handle* fsGetSessionHandle(void)
{ {
return &fsuHandle; return &fsuHandle;