Added splash support (#2)

Combination of quality of life improvements, bugfixes and splash support:

* unzip_file now works with any file, not just a theme

* Made linked list nodes generic so they work for both splashes and themes

* Fixed bug in previous commit with deleting the zip file once it was unzipped

* All zips in /Splashes/ are now extracted, as with /Themes/

* Splashes are all added to the linked list properly

* Splashes can be installed given a path, but only works on Luma. Undecided as to whether or not I'm going to change this.

TODO:

* Automatically change the luma configuration to enable splash screens

* MAYBE add support for other CFWs (if there's an interest). Maybe set a folder to extract splashes to in some kind of user settings?
This commit is contained in:
Alex Taber
2017-07-21 20:49:17 -04:00
committed by GitHub
parent 217846bca4
commit 37aa9022e1
9 changed files with 212 additions and 46 deletions

View File

@@ -73,9 +73,8 @@ Result extract_current_file(unzFile zip_handle, u16 *theme_path)
}
// TODO: There's a lot of duplicated code here, especially considering that we already built the paths in prepare_themes(). Maybe clean it up a bit later
Result unzip_theme(FS_DirectoryEntry *entry, u16 *sanitized_name)
Result unzip_file(char* base_path, FS_DirectoryEntry *entry, u16 *sanitized_name)
{
char *base_path = "/Themes/";
u16 zip_path[sizeof(entry->name) + 18] = {0}; // Make two u16*s that are big enough to hold the entire path
u16 uzipfile[sizeof(entry->name) + 18] = {0};
atow(zip_path, base_path); // Copy "/Themes/" unicode equivalent into a path
@@ -109,8 +108,13 @@ Result unzip_theme(FS_DirectoryEntry *entry, u16 *sanitized_name)
extract_current_file(zip_handle, theme_path_u16);
while(unzGoToNextFile(zip_handle) == UNZ_OK) extract_current_file(zip_handle, theme_path_u16); // While next file exists, unzip it
unzClose(zip_handle);
res = FSUSER_DeleteFile(ArchiveSD, fsMakePath(PATH_ASCII, zipfile));
if (R_FAILED(res))
{
free(zipfile);
return res;
}
free(zipfile);
FSUSER_DeleteFile(ArchiveSD, fsMakePath(PATH_ASCII, zipfile));
return MAKERESULT(RL_SUCCESS, RS_SUCCESS, RM_COMMON, RD_SUCCESS); // And return success \o/
}
@@ -182,8 +186,8 @@ Result prepareThemes(node *first_node)
atow(sanitized_zip_path, "/Themes/");
memcpy(&sanitized_zip_path[len], sanitized_zip, sizeof(entry->name));
FSUSER_RenameFile(ArchiveSD, fsMakePath(PATH_UTF16, zip_path), ArchiveSD, fsMakePath(PATH_UTF16, sanitized_zip_path)); // Rename the zip to the sanitized one
unzip_theme(entry, sanitized_zip); // And unzip it
} else unzip_theme(entry, entry->name); // If it's the same, unzip it anyway
unzip_file("/Themes/", entry, sanitized_zip); // And unzip it
} else unzip_file("/Themes/", entry, entry->name); // If it's the same, unzip it anyway
}
free(entry);
} else {