finally got theme deletion working + qr stuff
Theme deletion [SDMC] now works, although no button currently has it assigned. The QR reader now works properly with Unicode filenames.
This commit is contained in:
@@ -51,7 +51,7 @@ int theme_count;
|
||||
|
||||
void load_theme_preview(Theme_s *theme);
|
||||
Result get_themes(Theme_s **themes_list, int *theme_count);
|
||||
void add_theme(Theme_s **themes_list, int *theme_count, char *path, char *filename);
|
||||
void del_theme(u16 *path);
|
||||
Result single_install(Theme_s theme);
|
||||
Result shuffle_install(Theme_s *themes_list, int theme_count);
|
||||
Result bgm_install(Theme_s bgm_to_install);
|
||||
|
||||
@@ -221,7 +221,7 @@ Result http_get(char *url, char *path)
|
||||
remake_file(path_to_file, ArchiveSD, size);
|
||||
buf_to_file(size, path_to_file, ArchiveSD, (char*)buf);
|
||||
|
||||
add_theme(&themes_list, &theme_count, path_to_file, filename);
|
||||
get_themes(&themes_list, &theme_count);
|
||||
|
||||
exit_qr();
|
||||
|
||||
|
||||
@@ -194,6 +194,9 @@ int main(void)
|
||||
draw_theme_install(SINGLE_INSTALL);
|
||||
single_install(*current_theme);
|
||||
}
|
||||
//these two are here just so I don't forget how to implement them - HM
|
||||
//del_theme(current_theme->path);
|
||||
//get_themes(&themes_list, &theme_count);
|
||||
}
|
||||
|
||||
else if (kDown & KEY_B)
|
||||
|
||||
@@ -158,7 +158,15 @@ Result get_themes(Theme_s **themes_list, int *theme_count)
|
||||
if (R_FAILED(res))
|
||||
return res;
|
||||
|
||||
if (*themes_list != NULL) //used for QR reading and also for theme deletion
|
||||
{
|
||||
free(*themes_list);
|
||||
*themes_list = NULL;
|
||||
*theme_count = 0;
|
||||
}
|
||||
|
||||
u32 entries_read = 1;
|
||||
|
||||
while (entries_read)
|
||||
{
|
||||
FS_DirectoryEntry entry = {0};
|
||||
@@ -196,25 +204,18 @@ Result get_themes(Theme_s **themes_list, int *theme_count)
|
||||
return res;
|
||||
}
|
||||
|
||||
void add_theme(Theme_s **themes_list, int *theme_count, char *path, char *filename)
|
||||
void del_theme(u16 *path)
|
||||
{
|
||||
*theme_count += 1;
|
||||
*themes_list = realloc(*themes_list, (*theme_count) * sizeof(Theme_s));
|
||||
|
||||
Theme_s *current_theme = &(*themes_list)[*theme_count - 1];
|
||||
memset(current_theme, 0, sizeof(Theme_s));
|
||||
|
||||
u16 theme_path[0x106] = {0};
|
||||
utf8_to_utf16(theme_path, (u8*)path, 0x106);
|
||||
|
||||
u16 ufilename[0x106] = {0};
|
||||
utf8_to_utf16(ufilename, (u8*)filename, 0x106);
|
||||
|
||||
memcpy(current_theme->path, theme_path, 0x106 * sizeof(u16));
|
||||
current_theme->is_zip = true;
|
||||
|
||||
ssize_t iconID = TEXTURE_PREVIEW + *theme_count;
|
||||
parse_smdh(current_theme, iconID, ufilename);
|
||||
Handle dir_handle;
|
||||
Result res = FSUSER_OpenDirectory(&dir_handle, ArchiveSD, fsMakePath(PATH_UTF16, path));
|
||||
if (R_SUCCEEDED(res))
|
||||
{
|
||||
FSDIR_Close(dir_handle);
|
||||
FSUSER_DeleteDirectoryRecursively(ArchiveSD, fsMakePath(PATH_UTF16, path));
|
||||
} else
|
||||
{
|
||||
FSUSER_DeleteFile(ArchiveSD, fsMakePath(PATH_UTF16, path));
|
||||
}
|
||||
}
|
||||
|
||||
Result bgm_install(Theme_s bgm_to_install)
|
||||
|
||||
Reference in New Issue
Block a user