Windows build fixes

This commit is contained in:
Jack Andersen 2019-11-24 15:17:57 -10:00
parent 48a2981a93
commit f147e12356
2 changed files with 19 additions and 19 deletions

View File

@ -65,49 +65,49 @@ public:
DiscIONFS(SystemStringView fpin, bool& err) { DiscIONFS(SystemStringView fpin, bool& err) {
/* Validate file path format */ /* Validate file path format */
using SignedSize = std::make_signed<SystemString::size_type>::type; using SignedSize = std::make_signed<SystemString::size_type>::type;
const auto dotPos = SignedSize(fpin.rfind('.')); const auto dotPos = SignedSize(fpin.rfind(_SYS_STR('.')));
const auto slashPos = SignedSize(fpin.find_last_of("/\\")); const auto slashPos = SignedSize(fpin.find_last_of(_SYS_STR("/\\")));
if (fpin.size() <= 4 || dotPos == -1 || dotPos <= slashPos || if (fpin.size() <= 4 || dotPos == -1 || dotPos <= slashPos ||
fpin.compare(slashPos + 1, 4, "hif_") || fpin.compare(slashPos + 1, 4, _SYS_STR("hif_")) ||
fpin.compare(dotPos, fpin.size() - dotPos, ".nfs")) { fpin.compare(dotPos, fpin.size() - dotPos, _SYS_STR(".nfs"))) {
LogModule.report(logvisor::Error, LogModule.report(logvisor::Error,
fmt("'{}' must begin with 'hif_' and end with '.nfs' to be accepted as an NFS image"), fpin); fmt(_SYS_STR("'{}' must begin with 'hif_' and end with '.nfs' to be accepted as an NFS image")), fpin);
err = true; err = true;
return; return;
} }
/* Load key file */ /* Load key file */
const SystemString dir(fpin.begin(), fpin.begin() + slashPos + 1); const SystemString dir(fpin.begin(), fpin.begin() + slashPos + 1);
auto keyFile = NewFileIO(dir + "../code/htk.bin")->beginReadStream(); auto keyFile = NewFileIO(dir + _SYS_STR("../code/htk.bin"))->beginReadStream();
if (!keyFile) if (!keyFile)
keyFile = NewFileIO(dir + "htk.bin")->beginReadStream(); keyFile = NewFileIO(dir + _SYS_STR("htk.bin"))->beginReadStream();
if (!keyFile) { if (!keyFile) {
LogModule.report(logvisor::Error, fmt("Unable to open '{}../code/htk.bin' or '{}htk.bin'"), dir, dir); LogModule.report(logvisor::Error, fmt(_SYS_STR("Unable to open '{}../code/htk.bin' or '{}htk.bin'")), dir, dir);
err = true; err = true;
return; return;
} }
if (keyFile->read(key, 16) != 16) { if (keyFile->read(key, 16) != 16) {
LogModule.report(logvisor::Error, fmt("Unable to read from '{}../code/htk.bin' or '{}htk.bin'"), dir, dir); LogModule.report(logvisor::Error, fmt(_SYS_STR("Unable to read from '{}../code/htk.bin' or '{}htk.bin'")), dir, dir);
err = true; err = true;
return; return;
} }
/* Load header from first file */ /* Load header from first file */
const SystemString firstPath = fmt::format(fmt("{}hif_{:06}.nfs"), dir, 0); const SystemString firstPath = fmt::format(fmt(_SYS_STR("{}hif_{:06}.nfs")), dir, 0);
files.push_back(NewFileIO(firstPath)); files.push_back(NewFileIO(firstPath));
auto rs = files.back()->beginReadStream(); auto rs = files.back()->beginReadStream();
if (!rs) { if (!rs) {
LogModule.report(logvisor::Error, fmt("'{}' does not exist"), firstPath); LogModule.report(logvisor::Error, fmt(_SYS_STR("'{}' does not exist")), firstPath);
err = true; err = true;
return; return;
} }
if (rs->read(&nfsHead, 0x200) != 0x200) { if (rs->read(&nfsHead, 0x200) != 0x200) {
LogModule.report(logvisor::Error, fmt("Unable to read header from '{}'"), firstPath); LogModule.report(logvisor::Error, fmt(_SYS_STR("Unable to read header from '{}'")), firstPath);
err = true; err = true;
return; return;
} }
if (std::memcmp(&nfsHead.magic, "EGGS", 4)) { if (std::memcmp(&nfsHead.magic, "EGGS", 4)) {
LogModule.report(logvisor::Error, fmt("Invalid magic in '{}'"), firstPath); LogModule.report(logvisor::Error, fmt(_SYS_STR("Invalid magic in '{}'")), firstPath);
err = true; err = true;
return; return;
} }
@ -122,10 +122,10 @@ public:
const uint32_t numFiles = calculateNumFiles(); const uint32_t numFiles = calculateNumFiles();
files.reserve(numFiles); files.reserve(numFiles);
for (uint32_t i = 1; i < numFiles; ++i) { for (uint32_t i = 1; i < numFiles; ++i) {
SystemString path = fmt::format(fmt("{}hif_{:06}.nfs"), dir, i); SystemString path = fmt::format(fmt(_SYS_STR("{}hif_{:06}.nfs")), dir, i);
files.push_back(NewFileIO(path)); files.push_back(NewFileIO(path));
if (!files.back()->exists()) { if (!files.back()->exists()) {
LogModule.report(logvisor::Error, fmt("'{}' does not exist"), path); LogModule.report(logvisor::Error, fmt(_SYS_STR("'{}' does not exist")), path);
err = true; err = true;
return; return;
} }

View File

@ -34,14 +34,14 @@ std::unique_ptr<DiscBase> OpenDiscFromImage(SystemStringView path, bool& isWii)
} }
using SignedSize = std::make_signed<SystemString::size_type>::type; using SignedSize = std::make_signed<SystemString::size_type>::type;
const auto dotPos = SignedSize(path.rfind('.')); const auto dotPos = SignedSize(path.rfind(_SYS_STR('.')));
const auto slashPos = SignedSize(path.find_last_of("/\\")); const auto slashPos = SignedSize(path.find_last_of(_SYS_STR("/\\")));
if (magic == nod::SBig((uint32_t)'WBFS')) { if (magic == nod::SBig((uint32_t)'WBFS')) {
discIO = NewDiscIOWBFS(path); discIO = NewDiscIOWBFS(path);
isWii = true; isWii = true;
} else if (path.size() > 4 && dotPos != -1 && dotPos > slashPos && } else if (path.size() > 4 && dotPos != -1 && dotPos > slashPos &&
!path.compare(slashPos + 1, 4, "hif_") && !path.compare(slashPos + 1, 4, _SYS_STR("hif_")) &&
!path.compare(dotPos, path.size() - dotPos, ".nfs")) { !path.compare(dotPos, path.size() - dotPos, _SYS_STR(".nfs"))) {
discIO = NewDiscIONFS(path); discIO = NewDiscIONFS(path);
isWii = true; isWii = true;
} else { } else {