Merge pull request #13274 from dpeukert/master
Clean up CRLF line endings
This commit is contained in:
commit
da0a0c87c2
|
@ -1,41 +1,41 @@
|
||||||
# RZDK01 - The Legend of Zelda: Twilight Princess [Wii]
|
# RZDK01 - The Legend of Zelda: Twilight Princess [Wii]
|
||||||
|
|
||||||
[OnFrame]
|
[OnFrame]
|
||||||
# Add memory patches to be applied every frame here.
|
# Add memory patches to be applied every frame here.
|
||||||
$Hyrule Field Speed Hack
|
$Hyrule Field Speed Hack
|
||||||
0x80047DEC:dword:0x60000000
|
0x80047DEC:dword:0x60000000
|
||||||
0x80047E08:dword:0x60000000
|
0x80047E08:dword:0x60000000
|
||||||
0x80047E20:dword:0x60000000
|
0x80047E20:dword:0x60000000
|
||||||
0x80047E3C:dword:0x60000000
|
0x80047E3C:dword:0x60000000
|
||||||
|
|
||||||
0x80047E40:dword:0x60000000
|
0x80047E40:dword:0x60000000
|
||||||
0x80047E44:dword:0x60000000
|
0x80047E44:dword:0x60000000
|
||||||
0x80047E48:dword:0x60000000
|
0x80047E48:dword:0x60000000
|
||||||
0x80047E4C:dword:0x60000000
|
0x80047E4C:dword:0x60000000
|
||||||
0x80047E50:dword:0x60000000
|
0x80047E50:dword:0x60000000
|
||||||
0x80047E54:dword:0x60000000
|
0x80047E54:dword:0x60000000
|
||||||
0x80047E58:dword:0x60000000
|
0x80047E58:dword:0x60000000
|
||||||
0x80047E5C:dword:0x60000000
|
0x80047E5C:dword:0x60000000
|
||||||
0x80047E60:dword:0x60000000
|
0x80047E60:dword:0x60000000
|
||||||
0x80047E64:dword:0x60000000
|
0x80047E64:dword:0x60000000
|
||||||
0x80047E68:dword:0x60000000
|
0x80047E68:dword:0x60000000
|
||||||
0x80047E6C:dword:0x60000000
|
0x80047E6C:dword:0x60000000
|
||||||
0x80047E70:dword:0x60000000
|
0x80047E70:dword:0x60000000
|
||||||
0x80047E74:dword:0x60000000
|
0x80047E74:dword:0x60000000
|
||||||
0x80047E78:dword:0x60000000
|
0x80047E78:dword:0x60000000
|
||||||
0x80047E7C:dword:0x60000000
|
0x80047E7C:dword:0x60000000
|
||||||
0x80047E80:dword:0x60000000
|
0x80047E80:dword:0x60000000
|
||||||
0x80047E84:dword:0x60000000
|
0x80047E84:dword:0x60000000
|
||||||
0x80047E88:dword:0x60000000
|
0x80047E88:dword:0x60000000
|
||||||
0x80047E8C:dword:0x60000000
|
0x80047E8C:dword:0x60000000
|
||||||
|
|
||||||
0x80047E94:dword:0x60000000
|
0x80047E94:dword:0x60000000
|
||||||
0x80047EB0:dword:0x60000000
|
0x80047EB0:dword:0x60000000
|
||||||
0x80047EC8:dword:0x60000000
|
0x80047EC8:dword:0x60000000
|
||||||
0x80047EE4:dword:0x60000000
|
0x80047EE4:dword:0x60000000
|
||||||
|
|
||||||
[Patches_RetroAchievements_Verified]
|
[Patches_RetroAchievements_Verified]
|
||||||
$Hyrule Field Speed Hack
|
$Hyrule Field Speed Hack
|
||||||
|
|
||||||
[ActionReplay]
|
[ActionReplay]
|
||||||
# Add action replay cheats here.
|
# Add action replay cheats here.
|
||||||
|
|
|
@ -1,132 +1,132 @@
|
||||||
// SPDX-License-Identifier: GPL-2.0-or-later
|
// SPDX-License-Identifier: GPL-2.0-or-later
|
||||||
|
|
||||||
package org.dolphinemu.dolphinemu.features.skylanders.ui
|
package org.dolphinemu.dolphinemu.features.skylanders.ui
|
||||||
|
|
||||||
import android.app.AlertDialog
|
import android.app.AlertDialog
|
||||||
import android.content.Intent
|
import android.content.Intent
|
||||||
import android.view.LayoutInflater
|
import android.view.LayoutInflater
|
||||||
import android.view.View
|
import android.view.View
|
||||||
import android.view.ViewGroup
|
import android.view.ViewGroup
|
||||||
import android.widget.AdapterView
|
import android.widget.AdapterView
|
||||||
import android.widget.AdapterView.OnItemClickListener
|
import android.widget.AdapterView.OnItemClickListener
|
||||||
import android.widget.ArrayAdapter
|
import android.widget.ArrayAdapter
|
||||||
import android.widget.Toast
|
import android.widget.Toast
|
||||||
import androidx.recyclerview.widget.RecyclerView
|
import androidx.recyclerview.widget.RecyclerView
|
||||||
import com.google.android.material.dialog.MaterialAlertDialogBuilder
|
import com.google.android.material.dialog.MaterialAlertDialogBuilder
|
||||||
import org.dolphinemu.dolphinemu.R
|
import org.dolphinemu.dolphinemu.R
|
||||||
import org.dolphinemu.dolphinemu.activities.EmulationActivity
|
import org.dolphinemu.dolphinemu.activities.EmulationActivity
|
||||||
import org.dolphinemu.dolphinemu.databinding.DialogCreateSkylanderBinding
|
import org.dolphinemu.dolphinemu.databinding.DialogCreateSkylanderBinding
|
||||||
import org.dolphinemu.dolphinemu.databinding.ListItemNfcFigureSlotBinding
|
import org.dolphinemu.dolphinemu.databinding.ListItemNfcFigureSlotBinding
|
||||||
import org.dolphinemu.dolphinemu.features.skylanders.SkylanderConfig
|
import org.dolphinemu.dolphinemu.features.skylanders.SkylanderConfig
|
||||||
import org.dolphinemu.dolphinemu.features.skylanders.SkylanderConfig.removeSkylander
|
import org.dolphinemu.dolphinemu.features.skylanders.SkylanderConfig.removeSkylander
|
||||||
import org.dolphinemu.dolphinemu.features.skylanders.model.SkylanderPair
|
import org.dolphinemu.dolphinemu.features.skylanders.model.SkylanderPair
|
||||||
|
|
||||||
class SkylanderSlotAdapter(
|
class SkylanderSlotAdapter(
|
||||||
private val slots: List<SkylanderSlot>,
|
private val slots: List<SkylanderSlot>,
|
||||||
private val activity: EmulationActivity
|
private val activity: EmulationActivity
|
||||||
) : RecyclerView.Adapter<SkylanderSlotAdapter.ViewHolder>(), OnItemClickListener {
|
) : RecyclerView.Adapter<SkylanderSlotAdapter.ViewHolder>(), OnItemClickListener {
|
||||||
class ViewHolder(var binding: ListItemNfcFigureSlotBinding) :
|
class ViewHolder(var binding: ListItemNfcFigureSlotBinding) :
|
||||||
RecyclerView.ViewHolder(binding.getRoot())
|
RecyclerView.ViewHolder(binding.getRoot())
|
||||||
|
|
||||||
private lateinit var binding: DialogCreateSkylanderBinding
|
private lateinit var binding: DialogCreateSkylanderBinding
|
||||||
|
|
||||||
override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): ViewHolder {
|
override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): ViewHolder {
|
||||||
val inflater = LayoutInflater.from(parent.context)
|
val inflater = LayoutInflater.from(parent.context)
|
||||||
val binding = ListItemNfcFigureSlotBinding.inflate(inflater, parent, false)
|
val binding = ListItemNfcFigureSlotBinding.inflate(inflater, parent, false)
|
||||||
return ViewHolder(binding)
|
return ViewHolder(binding)
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun onBindViewHolder(holder: ViewHolder, position: Int) {
|
override fun onBindViewHolder(holder: ViewHolder, position: Int) {
|
||||||
val slot = slots[position]
|
val slot = slots[position]
|
||||||
holder.binding.textFigureName.text = slot.label
|
holder.binding.textFigureName.text = slot.label
|
||||||
|
|
||||||
holder.binding.buttonClearFigure.setOnClickListener {
|
holder.binding.buttonClearFigure.setOnClickListener {
|
||||||
removeSkylander(slot.portalSlot)
|
removeSkylander(slot.portalSlot)
|
||||||
activity.clearSkylander(slot.slotNum)
|
activity.clearSkylander(slot.slotNum)
|
||||||
}
|
}
|
||||||
|
|
||||||
holder.binding.buttonLoadFigure.setOnClickListener {
|
holder.binding.buttonLoadFigure.setOnClickListener {
|
||||||
val loadSkylander = Intent(Intent.ACTION_OPEN_DOCUMENT)
|
val loadSkylander = Intent(Intent.ACTION_OPEN_DOCUMENT)
|
||||||
loadSkylander.addCategory(Intent.CATEGORY_OPENABLE)
|
loadSkylander.addCategory(Intent.CATEGORY_OPENABLE)
|
||||||
loadSkylander.type = "*/*"
|
loadSkylander.type = "*/*"
|
||||||
activity.setSkylanderData(0, 0, "", position)
|
activity.setSkylanderData(0, 0, "", position)
|
||||||
activity.startActivityForResult(
|
activity.startActivityForResult(
|
||||||
loadSkylander,
|
loadSkylander,
|
||||||
EmulationActivity.REQUEST_SKYLANDER_FILE
|
EmulationActivity.REQUEST_SKYLANDER_FILE
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
val inflater = LayoutInflater.from(activity)
|
val inflater = LayoutInflater.from(activity)
|
||||||
binding = DialogCreateSkylanderBinding.inflate(inflater)
|
binding = DialogCreateSkylanderBinding.inflate(inflater)
|
||||||
|
|
||||||
val nameList = SkylanderConfig.REVERSE_LIST_SKYLANDERS.keys.toMutableList()
|
val nameList = SkylanderConfig.REVERSE_LIST_SKYLANDERS.keys.toMutableList()
|
||||||
nameList.sort()
|
nameList.sort()
|
||||||
val skylanderNames: ArrayList<String> = ArrayList(nameList)
|
val skylanderNames: ArrayList<String> = ArrayList(nameList)
|
||||||
|
|
||||||
binding.skylanderDropdown.setAdapter(
|
binding.skylanderDropdown.setAdapter(
|
||||||
ArrayAdapter(
|
ArrayAdapter(
|
||||||
activity, R.layout.support_simple_spinner_dropdown_item,
|
activity, R.layout.support_simple_spinner_dropdown_item,
|
||||||
skylanderNames
|
skylanderNames
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
binding.skylanderDropdown.onItemClickListener = this
|
binding.skylanderDropdown.onItemClickListener = this
|
||||||
|
|
||||||
holder.binding.buttonCreateFigure.setOnClickListener {
|
holder.binding.buttonCreateFigure.setOnClickListener {
|
||||||
if (binding.getRoot().parent != null) {
|
if (binding.getRoot().parent != null) {
|
||||||
(binding.getRoot().parent as ViewGroup).removeAllViews()
|
(binding.getRoot().parent as ViewGroup).removeAllViews()
|
||||||
}
|
}
|
||||||
val createDialog = MaterialAlertDialogBuilder(activity)
|
val createDialog = MaterialAlertDialogBuilder(activity)
|
||||||
.setTitle(R.string.create_skylander_title)
|
.setTitle(R.string.create_skylander_title)
|
||||||
.setView(binding.getRoot())
|
.setView(binding.getRoot())
|
||||||
.setPositiveButton(R.string.create_figure, null)
|
.setPositiveButton(R.string.create_figure, null)
|
||||||
.setNegativeButton(R.string.cancel, null)
|
.setNegativeButton(R.string.cancel, null)
|
||||||
.show()
|
.show()
|
||||||
createDialog.getButton(AlertDialog.BUTTON_POSITIVE).setOnClickListener {
|
createDialog.getButton(AlertDialog.BUTTON_POSITIVE).setOnClickListener {
|
||||||
if (binding.skylanderId.text.toString().isNotBlank() &&
|
if (binding.skylanderId.text.toString().isNotBlank() &&
|
||||||
binding.skylanderVar.text.toString().isNotBlank()
|
binding.skylanderVar.text.toString().isNotBlank()
|
||||||
) {
|
) {
|
||||||
val createSkylander = Intent(Intent.ACTION_CREATE_DOCUMENT)
|
val createSkylander = Intent(Intent.ACTION_CREATE_DOCUMENT)
|
||||||
createSkylander.addCategory(Intent.CATEGORY_OPENABLE)
|
createSkylander.addCategory(Intent.CATEGORY_OPENABLE)
|
||||||
createSkylander.type = "*/*"
|
createSkylander.type = "*/*"
|
||||||
val id = binding.skylanderId.text.toString().toInt()
|
val id = binding.skylanderId.text.toString().toInt()
|
||||||
val variant = binding.skylanderVar.text.toString().toInt()
|
val variant = binding.skylanderVar.text.toString().toInt()
|
||||||
val name = SkylanderConfig.LIST_SKYLANDERS[SkylanderPair(id, variant)]
|
val name = SkylanderConfig.LIST_SKYLANDERS[SkylanderPair(id, variant)]
|
||||||
if (name != null) {
|
if (name != null) {
|
||||||
createSkylander.putExtra(
|
createSkylander.putExtra(
|
||||||
Intent.EXTRA_TITLE,
|
Intent.EXTRA_TITLE,
|
||||||
"$name.sky"
|
"$name.sky"
|
||||||
)
|
)
|
||||||
activity.setSkylanderData(id, variant, name, position)
|
activity.setSkylanderData(id, variant, name, position)
|
||||||
} else {
|
} else {
|
||||||
createSkylander.putExtra(
|
createSkylander.putExtra(
|
||||||
Intent.EXTRA_TITLE,
|
Intent.EXTRA_TITLE,
|
||||||
"Unknown(ID: " + id + "Variant: " + variant + ").sky"
|
"Unknown(ID: " + id + "Variant: " + variant + ").sky"
|
||||||
)
|
)
|
||||||
activity.setSkylanderData(id, variant, "Unknown", position)
|
activity.setSkylanderData(id, variant, "Unknown", position)
|
||||||
}
|
}
|
||||||
activity.startActivityForResult(
|
activity.startActivityForResult(
|
||||||
createSkylander,
|
createSkylander,
|
||||||
EmulationActivity.REQUEST_CREATE_SKYLANDER
|
EmulationActivity.REQUEST_CREATE_SKYLANDER
|
||||||
)
|
)
|
||||||
createDialog.dismiss()
|
createDialog.dismiss()
|
||||||
} else {
|
} else {
|
||||||
Toast.makeText(
|
Toast.makeText(
|
||||||
activity, R.string.invalid_skylander,
|
activity, R.string.invalid_skylander,
|
||||||
Toast.LENGTH_SHORT
|
Toast.LENGTH_SHORT
|
||||||
).show()
|
).show()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun getItemCount(): Int {
|
override fun getItemCount(): Int {
|
||||||
return slots.size
|
return slots.size
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun onItemClick(parent: AdapterView<*>, view: View, position: Int, id: Long) {
|
override fun onItemClick(parent: AdapterView<*>, view: View, position: Int, id: Long) {
|
||||||
val skylanderIdVar =
|
val skylanderIdVar =
|
||||||
SkylanderConfig.REVERSE_LIST_SKYLANDERS[parent.getItemAtPosition(position)]
|
SkylanderConfig.REVERSE_LIST_SKYLANDERS[parent.getItemAtPosition(position)]
|
||||||
binding.skylanderId.setText(skylanderIdVar!!.id.toString())
|
binding.skylanderId.setText(skylanderIdVar!!.id.toString())
|
||||||
binding.skylanderVar.setText(skylanderIdVar.variant.toString())
|
binding.skylanderVar.setText(skylanderIdVar.variant.toString())
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,72 +1,72 @@
|
||||||
<?xml version="1.0" encoding="utf-8"?>
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
<androidx.constraintlayout.widget.ConstraintLayout android:id="@+id/root"
|
<androidx.constraintlayout.widget.ConstraintLayout android:id="@+id/root"
|
||||||
xmlns:android="http://schemas.android.com/apk/res/android"
|
xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
xmlns:app="http://schemas.android.com/apk/res-auto"
|
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="match_parent"
|
android:layout_height="match_parent"
|
||||||
android:padding="@dimen/spacing_medlarge">
|
android:padding="@dimen/spacing_medlarge">
|
||||||
|
|
||||||
<com.google.android.material.textfield.TextInputLayout
|
<com.google.android.material.textfield.TextInputLayout
|
||||||
android:id="@+id/layout_skylander_dropdown"
|
android:id="@+id/layout_skylander_dropdown"
|
||||||
style="@style/Widget.Material3.TextInputLayout.OutlinedBox.ExposedDropdownMenu"
|
style="@style/Widget.Material3.TextInputLayout.OutlinedBox.ExposedDropdownMenu"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:paddingBottom="@dimen/spacing_medlarge"
|
android:paddingBottom="@dimen/spacing_medlarge"
|
||||||
android:paddingHorizontal="@dimen/spacing_medlarge"
|
android:paddingHorizontal="@dimen/spacing_medlarge"
|
||||||
android:hint="@string/skylander_label"
|
android:hint="@string/skylander_label"
|
||||||
app:layout_constraintEnd_toEndOf="parent"
|
app:layout_constraintEnd_toEndOf="parent"
|
||||||
app:layout_constraintStart_toStartOf="parent"
|
app:layout_constraintStart_toStartOf="parent"
|
||||||
app:layout_constraintTop_toTopOf="parent">
|
app:layout_constraintTop_toTopOf="parent">
|
||||||
|
|
||||||
<com.google.android.material.textfield.MaterialAutoCompleteTextView
|
<com.google.android.material.textfield.MaterialAutoCompleteTextView
|
||||||
android:id="@+id/skylander_dropdown"
|
android:id="@+id/skylander_dropdown"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:spinnerMode="dialog"
|
android:spinnerMode="dialog"
|
||||||
android:imeOptions="actionDone" />
|
android:imeOptions="actionDone" />
|
||||||
|
|
||||||
</com.google.android.material.textfield.TextInputLayout>
|
</com.google.android.material.textfield.TextInputLayout>
|
||||||
|
|
||||||
<LinearLayout
|
<LinearLayout
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:orientation="horizontal"
|
android:orientation="horizontal"
|
||||||
app:layout_constraintTop_toBottomOf="@+id/layout_skylander_dropdown"
|
app:layout_constraintTop_toBottomOf="@+id/layout_skylander_dropdown"
|
||||||
android:gravity="center_vertical"
|
android:gravity="center_vertical"
|
||||||
android:baselineAligned="false">
|
android:baselineAligned="false">
|
||||||
|
|
||||||
<com.google.android.material.textfield.TextInputLayout
|
<com.google.android.material.textfield.TextInputLayout
|
||||||
android:id="@+id/layout_skylander_id"
|
android:id="@+id/layout_skylander_id"
|
||||||
android:layout_width="0dp"
|
android:layout_width="0dp"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:layout_weight="1"
|
android:layout_weight="1"
|
||||||
android:hint="@string/skylander_id"
|
android:hint="@string/skylander_id"
|
||||||
android:paddingHorizontal="@dimen/spacing_medlarge">
|
android:paddingHorizontal="@dimen/spacing_medlarge">
|
||||||
|
|
||||||
<com.google.android.material.textfield.TextInputEditText
|
<com.google.android.material.textfield.TextInputEditText
|
||||||
android:id="@+id/skylander_id"
|
android:id="@+id/skylander_id"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:inputType="number" />
|
android:inputType="number" />
|
||||||
|
|
||||||
</com.google.android.material.textfield.TextInputLayout>
|
</com.google.android.material.textfield.TextInputLayout>
|
||||||
|
|
||||||
<com.google.android.material.textfield.TextInputLayout
|
<com.google.android.material.textfield.TextInputLayout
|
||||||
android:id="@+id/layout_skylander_var"
|
android:id="@+id/layout_skylander_var"
|
||||||
android:layout_width="0dp"
|
android:layout_width="0dp"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:layout_weight="1"
|
android:layout_weight="1"
|
||||||
android:hint="@string/skylander_variant"
|
android:hint="@string/skylander_variant"
|
||||||
android:paddingHorizontal="@dimen/spacing_medlarge">
|
android:paddingHorizontal="@dimen/spacing_medlarge">
|
||||||
|
|
||||||
<com.google.android.material.textfield.TextInputEditText
|
<com.google.android.material.textfield.TextInputEditText
|
||||||
android:id="@+id/skylander_var"
|
android:id="@+id/skylander_var"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:inputType="number" />
|
android:inputType="number" />
|
||||||
|
|
||||||
</com.google.android.material.textfield.TextInputLayout>
|
</com.google.android.material.textfield.TextInputLayout>
|
||||||
|
|
||||||
</LinearLayout>
|
</LinearLayout>
|
||||||
|
|
||||||
</androidx.constraintlayout.widget.ConstraintLayout>
|
</androidx.constraintlayout.widget.ConstraintLayout>
|
||||||
|
|
|
@ -1,48 +1,48 @@
|
||||||
// Copyright 2019 Dolphin Emulator Project
|
// Copyright 2019 Dolphin Emulator Project
|
||||||
// SPDX-License-Identifier: GPL-2.0-or-later
|
// SPDX-License-Identifier: GPL-2.0-or-later
|
||||||
|
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include <algorithm>
|
#include <algorithm>
|
||||||
|
|
||||||
#include <mz_compat.h>
|
#include <mz_compat.h>
|
||||||
|
|
||||||
#include "Common/CommonTypes.h"
|
#include "Common/CommonTypes.h"
|
||||||
#include "Common/ScopeGuard.h"
|
#include "Common/ScopeGuard.h"
|
||||||
|
|
||||||
namespace Common
|
namespace Common
|
||||||
{
|
{
|
||||||
// Reads all of the current file. destination must be big enough to fit the whole file.
|
// Reads all of the current file. destination must be big enough to fit the whole file.
|
||||||
inline bool ReadFileFromZip(unzFile file, u8* destination, u64 len)
|
inline bool ReadFileFromZip(unzFile file, u8* destination, u64 len)
|
||||||
{
|
{
|
||||||
const u64 MAX_BUFFER_SIZE = 65535;
|
const u64 MAX_BUFFER_SIZE = 65535;
|
||||||
|
|
||||||
if (unzOpenCurrentFile(file) != UNZ_OK)
|
if (unzOpenCurrentFile(file) != UNZ_OK)
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
Common::ScopeGuard guard{[&] { unzCloseCurrentFile(file); }};
|
Common::ScopeGuard guard{[&] { unzCloseCurrentFile(file); }};
|
||||||
|
|
||||||
u64 bytes_to_go = len;
|
u64 bytes_to_go = len;
|
||||||
while (bytes_to_go > 0)
|
while (bytes_to_go > 0)
|
||||||
{
|
{
|
||||||
// NOTE: multiples of 4G can't cause read_len == 0 && bytes_to_go > 0, as MAX_BUFFER_SIZE is
|
// NOTE: multiples of 4G can't cause read_len == 0 && bytes_to_go > 0, as MAX_BUFFER_SIZE is
|
||||||
// small.
|
// small.
|
||||||
const u32 read_len = static_cast<u32>(std::min(bytes_to_go, MAX_BUFFER_SIZE));
|
const u32 read_len = static_cast<u32>(std::min(bytes_to_go, MAX_BUFFER_SIZE));
|
||||||
const int rv = unzReadCurrentFile(file, destination, read_len);
|
const int rv = unzReadCurrentFile(file, destination, read_len);
|
||||||
if (rv < 0)
|
if (rv < 0)
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
const u32 bytes_read = static_cast<u32>(rv);
|
const u32 bytes_read = static_cast<u32>(rv);
|
||||||
bytes_to_go -= bytes_read;
|
bytes_to_go -= bytes_read;
|
||||||
destination += bytes_read;
|
destination += bytes_read;
|
||||||
}
|
}
|
||||||
|
|
||||||
return unzEndOfFile(file) == 1;
|
return unzEndOfFile(file) == 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
template <typename ContiguousContainer>
|
template <typename ContiguousContainer>
|
||||||
bool ReadFileFromZip(unzFile file, ContiguousContainer* destination)
|
bool ReadFileFromZip(unzFile file, ContiguousContainer* destination)
|
||||||
{
|
{
|
||||||
return ReadFileFromZip(file, reinterpret_cast<u8*>(destination->data()), destination->size());
|
return ReadFileFromZip(file, reinterpret_cast<u8*>(destination->data()), destination->size());
|
||||||
}
|
}
|
||||||
} // namespace Common
|
} // namespace Common
|
||||||
|
|
Loading…
Reference in New Issue