[nostalgia/tools/pack] Use ox::preload function instead of bare model function in preloading
This commit is contained in:
parent
d68d8531e9
commit
7322056df2
@ -16,8 +16,6 @@
|
|||||||
|
|
||||||
namespace nostalgia {
|
namespace nostalgia {
|
||||||
|
|
||||||
using Preloader = ox::ModelHandlerInterface<GbaPreloader>;
|
|
||||||
|
|
||||||
static ox::Error pathToInode(ox::FileSystem *dest, ox::ModelObject *obj) noexcept {
|
static ox::Error pathToInode(ox::FileSystem *dest, ox::ModelObject *obj) noexcept {
|
||||||
auto &o = *obj;
|
auto &o = *obj;
|
||||||
auto type = static_cast<ox::FileAddressType>(o["type"].get<int8_t>());
|
auto type = static_cast<ox::FileAddressType>(o["type"].get<int8_t>());
|
||||||
@ -145,13 +143,14 @@ static ox::Error copy(ox::FileSystem *src, ox::FileSystem *dest, ox::CRString pa
|
|||||||
}
|
}
|
||||||
|
|
||||||
// transformations need to be done after the copy to the new FS is complete
|
// transformations need to be done after the copy to the new FS is complete
|
||||||
static ox::Error preloadObj(core::TypeStore *ts, ox::FileSystem *romFs, Preloader *pl, ox::CRString path) noexcept {
|
static ox::Error preloadObj(core::TypeStore *ts, ox::FileSystem *romFs, GbaPreloader *pl, ox::CRString path) noexcept {
|
||||||
// load file
|
// load file
|
||||||
oxRequireM(buff, romFs->read(path.c_str()));
|
oxRequireM(buff, romFs->read(path.c_str()));
|
||||||
oxRequireM(obj, ox::readClaw(ts, buff));
|
oxRequireM(obj, ox::readClaw(ts, buff));
|
||||||
if (obj.type()->preloadable) {
|
if (obj.type()->preloadable) {
|
||||||
// preload
|
// preload
|
||||||
oxReturnError(model(pl, &obj));
|
auto err = ox::preload<GbaPlatSpec, decltype(obj)>(pl, &obj);
|
||||||
|
oxReturnError(err);
|
||||||
const core::PreloadPtr p{.preloadAddr = 0};
|
const core::PreloadPtr p{.preloadAddr = 0};
|
||||||
oxReturnError(ox::writeMC(&p).moveTo(&buff));
|
oxReturnError(ox::writeMC(&p).moveTo(&buff));
|
||||||
} else {
|
} else {
|
||||||
@ -164,7 +163,7 @@ static ox::Error preloadObj(core::TypeStore *ts, ox::FileSystem *romFs, Preloade
|
|||||||
|
|
||||||
// claw file transformations are broken out because path to inode
|
// claw file transformations are broken out because path to inode
|
||||||
// transformations need to be done after the copy to the new FS is complete
|
// transformations need to be done after the copy to the new FS is complete
|
||||||
static ox::Error preload(core::TypeStore *ts, ox::FileSystem *romFs, Preloader *pl, ox::CRString path) noexcept {
|
static ox::Error preloadDir(core::TypeStore *ts, ox::FileSystem *romFs, GbaPreloader *pl, ox::CRString path) noexcept {
|
||||||
// copy
|
// copy
|
||||||
oxTracef("pack::preload", "path: {}", path);
|
oxTracef("pack::preload", "path: {}", path);
|
||||||
oxRequire(fileList, romFs->ls(path));
|
oxRequire(fileList, romFs->ls(path));
|
||||||
@ -173,7 +172,7 @@ static ox::Error preload(core::TypeStore *ts, ox::FileSystem *romFs, Preloader *
|
|||||||
oxRequire(stat, romFs->stat(filePath.c_str()));
|
oxRequire(stat, romFs->stat(filePath.c_str()));
|
||||||
if (stat.fileType == ox::FileType::Directory) {
|
if (stat.fileType == ox::FileType::Directory) {
|
||||||
const auto dir = path + name + '/';
|
const auto dir = path + name + '/';
|
||||||
oxReturnError(preload(ts, romFs, pl, dir));
|
oxReturnError(preloadDir(ts, romFs, pl, dir));
|
||||||
} else {
|
} else {
|
||||||
oxReturnError(preloadObj(ts, romFs, pl, filePath));
|
oxReturnError(preloadObj(ts, romFs, pl, filePath));
|
||||||
}
|
}
|
||||||
@ -211,7 +210,7 @@ ox::Error pack(core::TypeStore *ts, ox::FileSystem *src, ox::FileSystem *dest) n
|
|||||||
}
|
}
|
||||||
|
|
||||||
ox::Error preload(core::TypeStore *ts, ox::FileSystem *src, GbaPreloader *pl) noexcept {
|
ox::Error preload(core::TypeStore *ts, ox::FileSystem *src, GbaPreloader *pl) noexcept {
|
||||||
return preload(ts, src, pl->interface(), "/");
|
return preloadDir(ts, src, pl, "/");
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user