mirror of
https://github.com/joel16/3DSident.git
synced 2024-11-23 03:29:45 +00:00
Update FS functions
Removed FS_RecursiveMakeDir because it is unused.
This commit is contained in:
parent
833fbad1c4
commit
2dcd466f97
22
common/fs.c
22
common/fs.c
@ -2,8 +2,9 @@
|
||||
#include <string.h>
|
||||
|
||||
#include "fs.h"
|
||||
#include "utils.h"
|
||||
|
||||
Result FS_OpenArchive(FS_Archive * archive, FS_ArchiveID archiveID)
|
||||
Result FS_OpenArchive(FS_Archive *archive, FS_ArchiveID archiveID)
|
||||
{
|
||||
Result ret = 0;
|
||||
|
||||
@ -23,11 +24,14 @@ Result FS_CloseArchive(FS_Archive archive)
|
||||
return 0;
|
||||
}
|
||||
|
||||
Result FS_MakeDir(FS_Archive archive, const char * path)
|
||||
Result FS_MakeDir(FS_Archive archive, const char *path)
|
||||
{
|
||||
Result ret = 0;
|
||||
|
||||
if (R_FAILED(ret = FSUSER_CreateDirectory(archive, fsMakePath(PATH_ASCII, path), 0)))
|
||||
u16 path_u16[strlen(path) + 1];
|
||||
Utils_U8_To_U16(path_u16, path, strlen(path) + 1);
|
||||
|
||||
if (R_FAILED(ret = FSUSER_CreateDirectory(archive, fsMakePath(PATH_UTF16, path_u16), 0)))
|
||||
return ret;
|
||||
|
||||
return 0;
|
||||
@ -67,7 +71,10 @@ bool FS_FileExists(FS_Archive archive, const char * path)
|
||||
{
|
||||
Handle handle;
|
||||
|
||||
if (R_FAILED(FSUSER_OpenFile(&handle, archive, fsMakePath(PATH_ASCII, path), FS_OPEN_READ, 0)))
|
||||
u16 path_u16[strlen(path) + 1];
|
||||
Utils_U8_To_U16(path_u16, path, strlen(path) + 1);
|
||||
|
||||
if (R_FAILED(FSUSER_OpenFile(&handle, archive, fsMakePath(PATH_UTF16, path_u16), FS_OPEN_READ, 0)))
|
||||
return false;
|
||||
|
||||
if (R_FAILED(FSFILE_Close(handle)))
|
||||
@ -76,11 +83,14 @@ bool FS_FileExists(FS_Archive archive, const char * path)
|
||||
return true;
|
||||
}
|
||||
|
||||
bool FS_DirExists(FS_Archive archive, const char * path)
|
||||
bool FS_DirExists(FS_Archive archive, const char *path)
|
||||
{
|
||||
Handle handle;
|
||||
|
||||
if (R_FAILED(FSUSER_OpenDirectory(&handle, archive, fsMakePath(PATH_ASCII, path))))
|
||||
u16 path_u16[strlen(path) + 1];
|
||||
Utils_U8_To_U16(path_u16, path, strlen(path) + 1);
|
||||
|
||||
if (R_FAILED(FSUSER_OpenDirectory(&handle, archive, fsMakePath(PATH_UTF16, path_u16))))
|
||||
return false;
|
||||
|
||||
if (R_FAILED(FSDIR_Close(handle)))
|
||||
|
@ -5,11 +5,10 @@
|
||||
|
||||
FS_Archive archive;
|
||||
|
||||
Result FS_OpenArchive(FS_Archive * archive, FS_ArchiveID id);
|
||||
Result FS_OpenArchive(FS_Archive *archive, FS_ArchiveID archiveID);
|
||||
Result FS_CloseArchive(FS_Archive archive);
|
||||
Result FS_MakeDir(FS_Archive archive, const char * path);
|
||||
Result FS_RecursiveMakeDir(FS_Archive archive, const char * dir);
|
||||
bool FS_FileExists(FS_Archive archive, const char * path);
|
||||
bool FS_DirExists(FS_Archive archive, const char * path);
|
||||
Result FS_MakeDir(FS_Archive archive, const char *path);
|
||||
bool FS_FileExists(FS_Archive archive, const char *path);
|
||||
bool FS_DirExists(FS_Archive archive, const char *path);
|
||||
|
||||
#endif
|
@ -1,5 +1,4 @@
|
||||
#include <3ds.h>
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
@ -9,7 +8,7 @@
|
||||
|
||||
static int num = 0;
|
||||
|
||||
static Result generateScreenshot(const char * path)
|
||||
static Result generateScreenshot(const char *path)
|
||||
{
|
||||
int x = 0, y = 0;
|
||||
Handle handle;
|
||||
@ -19,15 +18,15 @@ static Result generateScreenshot(const char * path)
|
||||
Result ret = 0;
|
||||
|
||||
// Get top/bottom framebuffers
|
||||
u8 * gfxBottom = gfxGetFramebuffer(GFX_BOTTOM, GFX_BOTTOM, NULL, NULL);
|
||||
u8 * gfxTopLeft = gfxGetFramebuffer(GFX_TOP, GFX_LEFT, NULL, NULL);
|
||||
u8 *gfxBottom = gfxGetFramebuffer(GFX_BOTTOM, GFX_BOTTOM, NULL, NULL);
|
||||
u8 *gfxTopLeft = gfxGetFramebuffer(GFX_TOP, GFX_LEFT, NULL, NULL);
|
||||
|
||||
// Open file for writing screenshot
|
||||
if (R_FAILED(ret = FSUSER_OpenFile(&handle, archive, fsMakePath(PATH_ASCII, path), (FS_OPEN_CREATE | FS_OPEN_WRITE), 0)))
|
||||
return ret;
|
||||
|
||||
// Some
|
||||
u8 * buf = (u8*)malloc(size + 576000);
|
||||
u8 *buf = (u8*)malloc(size + 576000);
|
||||
memset(buf, 0, size + 576000);
|
||||
buf[size + 576000] = 0;
|
||||
|
||||
|
@ -40,6 +40,16 @@ void Utils_U16_To_U8(char *buf, const u16 *input, size_t bufsize)
|
||||
buf[units] = 0;
|
||||
}
|
||||
|
||||
void Utils_U8_To_U16(u16 *buf, const char *input, size_t bufsize)
|
||||
{
|
||||
ssize_t units = utf8_to_utf16(buf, (const uint8_t*)input, bufsize);
|
||||
|
||||
if (units < 0)
|
||||
units = 0;
|
||||
|
||||
buf[units] = 0;
|
||||
}
|
||||
|
||||
char *Utils_ExtractBetween(const char *string, const char *str1, const char *str2)
|
||||
{
|
||||
const char *i1 = strstr(string, str1);
|
||||
|
@ -6,6 +6,7 @@
|
||||
void Utils_GetSizeString(char *string, uint64_t size);
|
||||
bool Utils_IsN3DS(void);
|
||||
void Utils_U16_To_U8(char *buf, const u16 *input, size_t bufsize);
|
||||
void Utils_U8_To_U16(u16 *buf, const char *input, size_t bufsize);
|
||||
char *Utils_ExtractBetween(const char *string, const char *str1, const char *str2);
|
||||
char *Utils_Base64Encode(u8 const *bytesToEnc, size_t bufLen);
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user