Add Installer Info for Progress
This commit is contained in:
parent
fae31a2b28
commit
ce30d00385
@ -21,5 +21,13 @@
|
|||||||
#include <string>
|
#include <string>
|
||||||
|
|
||||||
namespace RenderD7 {
|
namespace RenderD7 {
|
||||||
|
struct InstallerInfo {
|
||||||
|
unsigned long long total;
|
||||||
|
unsigned long long current;
|
||||||
|
unsigned int mem_size = 0x80000;
|
||||||
|
bool active = false;
|
||||||
|
};
|
||||||
Result InstallCia(const std::string& path, bool self);
|
Result InstallCia(const std::string& path, bool self);
|
||||||
}
|
void InstallSetBuffersSize(unsigned int bytes);
|
||||||
|
InstallerInfo InstallGetInfo();
|
||||||
|
} // namespace RenderD7
|
@ -68,13 +68,25 @@ FS_MediaType GetTitleDest(u64 id) {
|
|||||||
: MEDIATYPE_SD;
|
: MEDIATYPE_SD;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Variables. */
|
InstallerInfo rd7i_installer_info;
|
||||||
u64 rd7i_install_size = 0, rd7i_install_offset = 0;
|
|
||||||
|
InstallerInfo InstallGetInfo() { return rd7i_installer_info; }
|
||||||
|
|
||||||
|
void InstallSetBuffersSize(unsigned int bytes) {
|
||||||
|
if (rd7i_installer_info.active) return;
|
||||||
|
if (bytes == 0) return;
|
||||||
|
if (bytes >= 0x200000) bytes = 0x200000;
|
||||||
|
rd7i_installer_info.mem_size = bytes;
|
||||||
|
}
|
||||||
|
|
||||||
Result InstallCia(const std::string& path, bool self) {
|
Result InstallCia(const std::string& path, bool self) {
|
||||||
if (!rd7i_is_am_init) return -1;
|
if (!rd7i_is_am_init) return -1;
|
||||||
u32 bytes_read = 0, bytes_written;
|
if (rd7i_installer_info.active) return -1;
|
||||||
rd7i_install_size = 0, rd7i_install_offset = 0;
|
u32 bytes_read = 0;
|
||||||
|
u32 bytes_written = 0;
|
||||||
|
rd7i_installer_info.current = 0;
|
||||||
|
// Set 1 to avoid div0 error
|
||||||
|
rd7i_installer_info.total = 1;
|
||||||
u64 size = 0;
|
u64 size = 0;
|
||||||
Handle cia, file;
|
Handle cia, file;
|
||||||
AM_TitleEntry info;
|
AM_TitleEntry info;
|
||||||
@ -123,22 +135,16 @@ Result InstallCia(const std::string& path, bool self) {
|
|||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
u32 toRead = 0x200000;
|
std::vector<unsigned char> buf(rd7i_installer_info.mem_size);
|
||||||
u8* buf = new u8[toRead];
|
rd7i_installer_info.total = size;
|
||||||
if (buf == nullptr) {
|
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
|
|
||||||
rd7i_install_size = size;
|
|
||||||
|
|
||||||
do {
|
do {
|
||||||
FSFILE_Read(file, &bytes_read, rd7i_install_offset, buf, toRead);
|
FSFILE_Read(file, &bytes_read, rd7i_installer_info.current, &buf[0],
|
||||||
FSFILE_Write(cia, &bytes_written, rd7i_install_offset, buf, toRead,
|
buf.size());
|
||||||
FS_WRITE_FLUSH);
|
FSFILE_Write(cia, &bytes_written, rd7i_installer_info.current, &buf[0],
|
||||||
rd7i_install_offset += bytes_read;
|
buf.size(), FS_WRITE_FLUSH);
|
||||||
} while (rd7i_install_offset < rd7i_install_size);
|
rd7i_installer_info.current += bytes_read;
|
||||||
|
} while (rd7i_installer_info.current < rd7i_installer_info.total);
|
||||||
delete[] buf;
|
|
||||||
|
|
||||||
ret = AM_FinishCiaInstall(cia);
|
ret = AM_FinishCiaInstall(cia);
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user