[nostalgia] Replace C strings with ox::StringView
This commit is contained in:
@@ -13,9 +13,9 @@
|
||||
|
||||
using namespace nostalgia;
|
||||
|
||||
static ox::Error writeFileBuff(ox::CRString path, const ox::Buffer &buff) noexcept {
|
||||
static ox::Error writeFileBuff(ox::CRStringView path, const ox::Buffer &buff) noexcept {
|
||||
try {
|
||||
std::ofstream f(path.c_str(), std::ios::binary);
|
||||
std::ofstream f(toStdStringView(path), std::ios::binary);
|
||||
f.write(buff.data(), static_cast<intptr_t>(buff.size()));
|
||||
} catch (const std::fstream::failure&) {
|
||||
return OxError(2, "failed to write file");
|
||||
@@ -23,8 +23,8 @@ static ox::Error writeFileBuff(ox::CRString path, const ox::Buffer &buff) noexce
|
||||
return {};
|
||||
}
|
||||
|
||||
static ox::Result<ox::Buffer> readFileBuff(const char *path) noexcept {
|
||||
std::ifstream file(path, std::ios::binary | std::ios::ate);
|
||||
static ox::Result<ox::Buffer> readFileBuff(ox::CRStringView path) noexcept {
|
||||
std::ifstream file(toStdStringView(path), std::ios::binary | std::ios::ate);
|
||||
if (!file.good()) {
|
||||
oxErrorf("Could not find OxFS file: {}", path);
|
||||
return OxError(1, "Could not find OxFS file");
|
||||
@@ -55,7 +55,7 @@ static ox::Error run(const ox::ClArgs &args) noexcept {
|
||||
}
|
||||
ox::Buffer dstBuff(32 * ox::units::MB);
|
||||
oxReturnError(ox::FileSystem32::format(dstBuff.data(), dstBuff.size()));
|
||||
ox::PassThroughFS src(argSrc.c_str());
|
||||
ox::PassThroughFS src(argSrc);
|
||||
ox::FileSystem32 dst(ox::FileStore32(dstBuff.data(), dstBuff.size()));
|
||||
core::TypeStore ts(&src);
|
||||
oxReturnError(pack(&ts, &src, &dst));
|
||||
@@ -66,7 +66,7 @@ static ox::Error run(const ox::ClArgs &args) noexcept {
|
||||
oxRequire(dstSize, dst.size());
|
||||
dstBuff.resize(dstSize);
|
||||
|
||||
oxRequireM(romBuff, readFileBuff(argRomBin.c_str()));
|
||||
oxRequireM(romBuff, readFileBuff(argRomBin));
|
||||
oxReturnError(appendBinary(&romBuff, &dstBuff, pl.get()));
|
||||
|
||||
oxOutf("Dest FS size: {} bytes\n", dstSize);
|
||||
|
||||
Reference in New Issue
Block a user