3
0
Fork 0
forked from suyu/suyu

android: Fix case bug for installing game content

The C++ side never made the filename lowercase when checking the extension. This just passes the pre-prepared extension to have it checked.
This commit is contained in:
Charles Lombardo 2023-09-26 00:25:20 -04:00
parent 4e855be38b
commit 5326ea63e5
3 changed files with 19 additions and 7 deletions

View file

@ -247,7 +247,12 @@ object NativeLibrary {
external fun setAppDirectory(directory: String)
external fun installFileToNand(filename: String): Int
/**
* Installs a nsp or xci file to nand
* @param filename String representation of file uri
* @param extension Lowercase string representation of file extension without "."
*/
external fun installFileToNand(filename: String, extension: String): Int
external fun initializeGpuDriver(
hookLibDir: String?,

View file

@ -523,7 +523,12 @@ class MainActivity : AppCompatActivity(), ThemeProvider {
var errorExtension = 0
var errorOther = 0
documents.forEach {
when (NativeLibrary.installFileToNand(it.toString())) {
when (
NativeLibrary.installFileToNand(
it.toString(),
FileUtil.getExtension(it)
)
) {
NativeLibrary.InstallFileToNandResult.Success -> {
installSuccess += 1
}

View file

@ -102,7 +102,7 @@ public:
m_native_window = native_window;
}
int InstallFileToNand(std::string filename) {
int InstallFileToNand(std::string filename, std::string file_extension) {
jconst copy_func = [](const FileSys::VirtualFile& src, const FileSys::VirtualFile& dest,
std::size_t block_size) {
if (src == nullptr || dest == nullptr) {
@ -134,12 +134,12 @@ public:
m_system.GetFileSystemController().CreateFactories(*m_vfs);
[[maybe_unused]] std::shared_ptr<FileSys::NSP> nsp;
if (filename.ends_with("nsp")) {
if (file_extension == "nsp") {
nsp = std::make_shared<FileSys::NSP>(m_vfs->OpenFile(filename, FileSys::Mode::Read));
if (nsp->IsExtractedType()) {
return InstallError;
}
} else if (filename.ends_with("xci")) {
} else if (file_extension == "xci") {
jconst xci =
std::make_shared<FileSys::XCI>(m_vfs->OpenFile(filename, FileSys::Mode::Read));
nsp = xci->GetSecurePartitionNSP();
@ -607,8 +607,10 @@ void Java_org_yuzu_yuzu_1emu_NativeLibrary_setAppDirectory(JNIEnv* env, jobject
}
int Java_org_yuzu_yuzu_1emu_NativeLibrary_installFileToNand(JNIEnv* env, jobject instance,
[[maybe_unused]] jstring j_file) {
return EmulationSession::GetInstance().InstallFileToNand(GetJString(env, j_file));
jstring j_file,
jstring j_file_extension) {
return EmulationSession::GetInstance().InstallFileToNand(GetJString(env, j_file),
GetJString(env, j_file_extension));
}
void JNICALL Java_org_yuzu_yuzu_1emu_NativeLibrary_initializeGpuDriver(JNIEnv* env, jclass clazz,