Brought changes over from master/#92
All commits post-this one should be on stable.
This commit is contained in:
40
source/fs.c
40
source/fs.c
@@ -43,7 +43,7 @@ Result open_archives(void)
|
|||||||
u32 archive1;
|
u32 archive1;
|
||||||
u32 archive2;
|
u32 archive2;
|
||||||
|
|
||||||
Result retValue;
|
Result res = 0;
|
||||||
|
|
||||||
FS_Path home;
|
FS_Path home;
|
||||||
FS_Path theme;
|
FS_Path theme;
|
||||||
@@ -68,9 +68,7 @@ Result open_archives(void)
|
|||||||
archive2 = 0x00;
|
archive2 = 0x00;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if(R_FAILED(res = FSUSER_OpenArchive(&ArchiveSD, ARCHIVE_SDMC, fsMakePath(PATH_EMPTY, "")))) return res;
|
||||||
retValue = FSUSER_OpenArchive(&ArchiveSD, ARCHIVE_SDMC, fsMakePath(PATH_EMPTY, ""));
|
|
||||||
if(R_FAILED(retValue)) return retValue;
|
|
||||||
|
|
||||||
FSUSER_CreateDirectory(ArchiveSD, fsMakePath(PATH_ASCII, "/Themes"), FS_ATTRIBUTE_DIRECTORY);
|
FSUSER_CreateDirectory(ArchiveSD, fsMakePath(PATH_ASCII, "/Themes"), FS_ATTRIBUTE_DIRECTORY);
|
||||||
FSUSER_CreateDirectory(ArchiveSD, fsMakePath(PATH_ASCII, "/Splashes"), FS_ATTRIBUTE_DIRECTORY);
|
FSUSER_CreateDirectory(ArchiveSD, fsMakePath(PATH_ASCII, "/Splashes"), FS_ATTRIBUTE_DIRECTORY);
|
||||||
@@ -79,19 +77,16 @@ Result open_archives(void)
|
|||||||
home.type = PATH_BINARY;
|
home.type = PATH_BINARY;
|
||||||
home.size = 0xC;
|
home.size = 0xC;
|
||||||
home.data = homeMenuPath;
|
home.data = homeMenuPath;
|
||||||
retValue = FSUSER_OpenArchive(&ArchiveHomeExt, ARCHIVE_EXTDATA, home);
|
if(R_FAILED(res = FSUSER_OpenArchive(&ArchiveHomeExt, ARCHIVE_EXTDATA, home))) return res;
|
||||||
if(R_FAILED(retValue)) return retValue;
|
|
||||||
|
|
||||||
u32 themePath[3] = {MEDIATYPE_SD, archive1, 0};
|
u32 themePath[3] = {MEDIATYPE_SD, archive1, 0};
|
||||||
theme.type = PATH_BINARY;
|
theme.type = PATH_BINARY;
|
||||||
theme.size = 0xC;
|
theme.size = 0xC;
|
||||||
theme.data = themePath;
|
theme.data = themePath;
|
||||||
retValue = FSUSER_OpenArchive(&ArchiveThemeExt, ARCHIVE_EXTDATA, theme);
|
if(R_FAILED(res = FSUSER_OpenArchive(&ArchiveThemeExt, ARCHIVE_EXTDATA, theme))) return res;
|
||||||
if(R_FAILED(retValue)) return retValue;
|
|
||||||
|
|
||||||
Handle test_handle;
|
Handle test_handle;
|
||||||
retValue = FSUSER_OpenFile(&test_handle, ArchiveThemeExt, fsMakePath(PATH_ASCII, "/ThemeManage.bin"), FS_OPEN_READ, 0);
|
if(R_FAILED(res = FSUSER_OpenFile(&test_handle, ArchiveThemeExt, fsMakePath(PATH_ASCII, "/ThemeManage.bin"), FS_OPEN_READ, 0))) return res;
|
||||||
if(R_FAILED(retValue)) return retValue;
|
|
||||||
FSFILE_Close(test_handle);
|
FSFILE_Close(test_handle);
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
@@ -99,14 +94,11 @@ Result open_archives(void)
|
|||||||
|
|
||||||
Result close_archives(void)
|
Result close_archives(void)
|
||||||
{
|
{
|
||||||
Result retValue;
|
Result res;
|
||||||
|
|
||||||
retValue = FSUSER_CloseArchive(ArchiveSD);
|
if(R_FAILED(res = FSUSER_CloseArchive(ArchiveSD))) return res;
|
||||||
if(R_FAILED(retValue)) return retValue;
|
if(R_FAILED(res = FSUSER_CloseArchive(ArchiveHomeExt))) return res;
|
||||||
retValue = FSUSER_CloseArchive(ArchiveHomeExt);
|
if(R_FAILED(res = FSUSER_CloseArchive(ArchiveThemeExt))) return res;
|
||||||
if(R_FAILED(retValue)) return retValue;
|
|
||||||
retValue = FSUSER_CloseArchive(ArchiveThemeExt);
|
|
||||||
if(R_FAILED(retValue)) return retValue;
|
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
@@ -114,8 +106,8 @@ Result close_archives(void)
|
|||||||
u64 file_to_buf(FS_Path path, FS_Archive archive, char** buf)
|
u64 file_to_buf(FS_Path path, FS_Archive archive, char** buf)
|
||||||
{
|
{
|
||||||
Handle file;
|
Handle file;
|
||||||
Result res = FSUSER_OpenFile(&file, archive, path, FS_OPEN_READ, 0);
|
Result res = 0;
|
||||||
if (R_FAILED(res)) return 0;
|
if (R_FAILED(res = FSUSER_OpenFile(&file, archive, path, FS_OPEN_READ, 0))) return 0;
|
||||||
|
|
||||||
u64 size;
|
u64 size;
|
||||||
FSFILE_GetSize(file, &size);
|
FSFILE_GetSize(file, &size);
|
||||||
@@ -162,12 +154,10 @@ u32 zip_file_to_buf(char *file_name, u16 *zip_path, char **buf)
|
|||||||
Result buf_to_file(u32 size, char *path, FS_Archive archive, char *buf)
|
Result buf_to_file(u32 size, char *path, FS_Archive archive, char *buf)
|
||||||
{
|
{
|
||||||
Handle handle;
|
Handle handle;
|
||||||
Result res = FSUSER_OpenFile(&handle, archive, fsMakePath(PATH_ASCII, path), FS_OPEN_WRITE, 0);
|
Result res = 0;
|
||||||
if (R_FAILED(res)) return res;
|
if (R_FAILED(res = FSUSER_OpenFile(&handle, archive, fsMakePath(PATH_ASCII, path), FS_OPEN_WRITE, 0))) return res;
|
||||||
res = FSFILE_Write(handle, NULL, 0, buf, size, FS_WRITE_FLUSH);
|
if (R_FAILED(res = FSFILE_Write(handle, NULL, 0, buf, size, FS_WRITE_FLUSH))) return res;
|
||||||
if (R_FAILED(res)) return res;
|
if (R_FAILED(res = FSFILE_Close(handle))) return res;
|
||||||
res = FSFILE_Close(handle);
|
|
||||||
if (R_FAILED(res)) return res;
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -56,8 +56,7 @@ void load_splash_preview(Splash_s *splash)
|
|||||||
u8 * image = NULL;
|
u8 * image = NULL;
|
||||||
unsigned int width = 0, height = 0;
|
unsigned int width = 0, height = 0;
|
||||||
|
|
||||||
int result = lodepng_decode32(&image, &width, &height, (u8*)preview_buffer, size);
|
if ((lodepng_decode32(&image, &width, &height, (u8*)preview_buffer, size)) == 0) // no error
|
||||||
if (result == 0) // no error
|
|
||||||
{
|
{
|
||||||
for (u32 i = 0; i < width; i++)
|
for (u32 i = 0; i < width; i++)
|
||||||
{
|
{
|
||||||
@@ -151,8 +150,8 @@ Result get_splashes(Splash_s** splashes_list, int *splash_count)
|
|||||||
{
|
{
|
||||||
Result res = 0;
|
Result res = 0;
|
||||||
Handle dir_handle;
|
Handle dir_handle;
|
||||||
res = FSUSER_OpenDirectory(&dir_handle, ArchiveSD, fsMakePath(PATH_ASCII, SPLASHES_PATH));
|
|
||||||
if (R_FAILED(res))
|
if (R_FAILED(res = FSUSER_OpenDirectory(&dir_handle, ArchiveSD, fsMakePath(PATH_ASCII, SPLASHES_PATH))))
|
||||||
return res;
|
return res;
|
||||||
|
|
||||||
if (*splashes_list != NULL)
|
if (*splashes_list != NULL)
|
||||||
@@ -166,8 +165,7 @@ Result get_splashes(Splash_s** splashes_list, int *splash_count)
|
|||||||
while (entries_read)
|
while (entries_read)
|
||||||
{
|
{
|
||||||
FS_DirectoryEntry entry = {0};
|
FS_DirectoryEntry entry = {0};
|
||||||
res = FSDIR_Read(dir_handle, &entries_read, 1, &entry);
|
if (R_FAILED(res = FSDIR_Read(dir_handle, &entries_read, 1, &entry)) || entries_read == 0)
|
||||||
if (R_FAILED(res) || entries_read == 0)
|
|
||||||
break;
|
break;
|
||||||
|
|
||||||
if (!(entry.attributes & FS_ATTRIBUTE_DIRECTORY) && strcmp(entry.shortExt, "ZIP"))
|
if (!(entry.attributes & FS_ATTRIBUTE_DIRECTORY) && strcmp(entry.shortExt, "ZIP"))
|
||||||
|
|||||||
Reference in New Issue
Block a user