diff options
| author | JosJuice <josjuice@gmail.com> | 2020-06-25 00:02:02 +0200 |
|---|---|---|
| committer | JosJuice <josjuice@gmail.com> | 2020-09-16 18:38:07 +0200 |
| commit | 7d6debb90793dbd34df49d779ea2c34e432094d8 (patch) | |
| tree | af32dc291701c0e06a586aaa4d0bb5b544f69840 /Source/Android/jni/MainAndroid.cpp | |
| parent | ca46028cdebdd379528245c6551f3ca83a1b9c55 (diff) | |
Android: Add disc image conversion
Diffstat (limited to 'Source/Android/jni/MainAndroid.cpp')
| -rw-r--r-- | Source/Android/jni/MainAndroid.cpp | 55 |
1 files changed, 55 insertions, 0 deletions
diff --git a/Source/Android/jni/MainAndroid.cpp b/Source/Android/jni/MainAndroid.cpp index 3dfafacf7c..bef78a49b5 100644 --- a/Source/Android/jni/MainAndroid.cpp +++ b/Source/Android/jni/MainAndroid.cpp @@ -18,6 +18,7 @@ #include <utility> #include "Common/AndroidAnalytics.h" +#include "Common/Assert.h" #include "Common/CPUDetect.h" #include "Common/CommonPaths.h" #include "Common/CommonTypes.h" @@ -45,7 +46,9 @@ #include "Core/State.h" #include "Core/WiiUtils.h" +#include "DiscIO/Blob.h" #include "DiscIO/Enums.h" +#include "DiscIO/ScrubbedBlob.h" #include "DiscIO/Volume.h" #include "InputCommon/ControllerInterface/Android/Android.h" @@ -663,6 +666,58 @@ JNIEXPORT jboolean JNICALL Java_org_dolphinemu_dolphinemu_NativeLibrary_InstallW return static_cast<jboolean>(WiiUtils::InstallWAD(path)); } +JNIEXPORT jboolean JNICALL Java_org_dolphinemu_dolphinemu_NativeLibrary_ConvertDiscImage( + JNIEnv* env, jobject obj, jstring jInPath, jstring jOutPath, jint jPlatform, jint jFormat, + jint jBlockSize, jint jCompression, jint jCompressionLevel, jboolean jScrub) +{ + const std::string in_path = GetJString(env, jInPath); + const std::string out_path = GetJString(env, jOutPath); + const DiscIO::Platform platform = static_cast<DiscIO::Platform>(jPlatform); + const DiscIO::BlobType format = static_cast<DiscIO::BlobType>(jFormat); + const DiscIO::WIARVZCompressionType compression = + static_cast<DiscIO::WIARVZCompressionType>(jCompression); + const bool scrub = static_cast<bool>(jScrub); + + std::unique_ptr<DiscIO::BlobReader> blob_reader; + if (scrub) + blob_reader = DiscIO::ScrubbedBlob::Create(in_path); + else + blob_reader = DiscIO::CreateBlobReader(in_path); + + if (!blob_reader) + return static_cast<jboolean>(false); + + const auto callback = [](const std::string& text, float percent) { return true; }; + + bool success = false; + + switch (format) + { + case DiscIO::BlobType::PLAIN: + success = DiscIO::ConvertToPlain(blob_reader.get(), in_path, out_path, callback); + break; + + case DiscIO::BlobType::GCZ: + success = + DiscIO::ConvertToGCZ(blob_reader.get(), in_path, out_path, + platform == DiscIO::Platform::WiiDisc ? 1 : 0, jBlockSize, callback); + break; + + case DiscIO::BlobType::WIA: + case DiscIO::BlobType::RVZ: + success = DiscIO::ConvertToWIAOrRVZ(blob_reader.get(), in_path, out_path, + format == DiscIO::BlobType::RVZ, compression, + jCompressionLevel, jBlockSize, callback); + break; + + default: + ASSERT(false); + break; + } + + return static_cast<jboolean>(success); +} + JNIEXPORT jstring JNICALL Java_org_dolphinemu_dolphinemu_NativeLibrary_FormatSize(JNIEnv* env, jobject obj, jlong bytes, |
