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