diff options
author | Charles Lombardo <clombardo169@gmail.com> | 2023-03-11 06:38:01 +0100 |
---|---|---|
committer | bunnei <bunneidev@gmail.com> | 2023-06-03 09:05:41 +0200 |
commit | a05c6deb666bdaa06a025c4b7c28e5d0e767fe43 (patch) | |
tree | b38d6af31f85f3bb9d3e5a0bb48b8d94aa4a16fa /src | |
parent | android: Convert GpuDriverHelper to Kotlin (diff) | |
download | yuzu-a05c6deb666bdaa06a025c4b7c28e5d0e767fe43.tar yuzu-a05c6deb666bdaa06a025c4b7c28e5d0e767fe43.tar.gz yuzu-a05c6deb666bdaa06a025c4b7c28e5d0e767fe43.tar.bz2 yuzu-a05c6deb666bdaa06a025c4b7c28e5d0e767fe43.tar.lz yuzu-a05c6deb666bdaa06a025c4b7c28e5d0e767fe43.tar.xz yuzu-a05c6deb666bdaa06a025c4b7c28e5d0e767fe43.tar.zst yuzu-a05c6deb666bdaa06a025c4b7c28e5d0e767fe43.zip |
Diffstat (limited to 'src')
-rw-r--r-- | src/android/app/src/main/java/org/yuzu/yuzu_emu/utils/GpuDriverMetadata.java | 45 | ||||
-rw-r--r-- | src/android/app/src/main/java/org/yuzu/yuzu_emu/utils/GpuDriverMetadata.kt | 44 |
2 files changed, 44 insertions, 45 deletions
diff --git a/src/android/app/src/main/java/org/yuzu/yuzu_emu/utils/GpuDriverMetadata.java b/src/android/app/src/main/java/org/yuzu/yuzu_emu/utils/GpuDriverMetadata.java deleted file mode 100644 index d2bb2dd23..000000000 --- a/src/android/app/src/main/java/org/yuzu/yuzu_emu/utils/GpuDriverMetadata.java +++ /dev/null @@ -1,45 +0,0 @@ -package org.yuzu.yuzu_emu.utils; - -import org.json.JSONException; -import org.json.JSONObject; - -import java.io.IOException; -import java.nio.charset.StandardCharsets; -import java.nio.file.Files; -import java.nio.file.Path; -import java.nio.file.Paths; - -public class GpuDriverMetadata { - - public String name; - public String description; - public String author; - public String vendor; - public String driverVersion; - public int minApi; - public String libraryName; - - public GpuDriverMetadata(String metadataFilePath) { - try { - JSONObject json = new JSONObject(getStringFromFile(metadataFilePath)); - name = json.getString("name"); - description = json.getString("description"); - author = json.getString("author"); - vendor = json.getString("vendor"); - driverVersion = json.getString("driverVersion"); - minApi = json.getInt("minApi"); - libraryName = json.getString("libraryName"); - } catch (JSONException e) { - // JSON is malformed, ignore and treat as unsupported metadata. - } catch (IOException e) { - // File is inaccessible, ignore and treat as unsupported metadata. - } - } - - private static String getStringFromFile(String filePath) throws IOException { - Path path = Paths.get(filePath); - byte[] bytes = Files.readAllBytes(path); - return new String(bytes, StandardCharsets.UTF_8); - } - -} diff --git a/src/android/app/src/main/java/org/yuzu/yuzu_emu/utils/GpuDriverMetadata.kt b/src/android/app/src/main/java/org/yuzu/yuzu_emu/utils/GpuDriverMetadata.kt new file mode 100644 index 000000000..732be3f63 --- /dev/null +++ b/src/android/app/src/main/java/org/yuzu/yuzu_emu/utils/GpuDriverMetadata.kt @@ -0,0 +1,44 @@ +package org.yuzu.yuzu_emu.utils + +import org.json.JSONException +import org.json.JSONObject +import java.io.IOException +import java.nio.charset.StandardCharsets +import java.nio.file.Files +import java.nio.file.Paths + +class GpuDriverMetadata(metadataFilePath: String) { + var name: String? = null + var description: String? = null + var author: String? = null + var vendor: String? = null + var driverVersion: String? = null + var minApi = 0 + var libraryName: String? = null + + init { + try { + val json = JSONObject(getStringFromFile(metadataFilePath)) + name = json.getString("name") + description = json.getString("description") + author = json.getString("author") + vendor = json.getString("vendor") + driverVersion = json.getString("driverVersion") + minApi = json.getInt("minApi") + libraryName = json.getString("libraryName") + } catch (e: JSONException) { + // JSON is malformed, ignore and treat as unsupported metadata. + } catch (e: IOException) { + // File is inaccessible, ignore and treat as unsupported metadata. + } + } + + companion object { + @Throws(IOException::class) + private fun getStringFromFile(filePath: String): String { + val path = Paths.get(filePath) + val bytes = Files.readAllBytes(path) + return String(bytes, StandardCharsets.UTF_8) + } + } +} |