diff options
author | 2023-09-17 11:33:25 -0400 | |
---|---|---|
committer | 2023-09-17 11:33:25 -0400 | |
commit | f5066881db7a601ba7031fbc996ab404e05e5dd5 (patch) | |
tree | 6803289651ccbc928e0141cf5a9392809e4dd00f /src/tools/image_handler.cpp | |
parent | 0af125686b70300486cb23c4d32c9c92ec369008 (diff) |
fsmgr.h: Cleanup
- Use multibyte.h functions for packing and unpacking words
- Remove a few aliases for cstdlib functions
- Convert rstr and wstr functions to std::string_view
Diffstat (limited to 'src/tools/image_handler.cpp')
-rw-r--r-- | src/tools/image_handler.cpp | 29 |
1 files changed, 14 insertions, 15 deletions
diff --git a/src/tools/image_handler.cpp b/src/tools/image_handler.cpp index 9e88c501a95..14a20818a38 100644 --- a/src/tools/image_handler.cpp +++ b/src/tools/image_handler.cpp @@ -12,6 +12,7 @@ #include "ioprocs.h" #include "ioprocsfill.h" #include "ioprocsvec.h" +#include "multibyte.h" #include "strformat.h" @@ -159,15 +160,14 @@ std::vector<u8> image_handler::fload_rsrc(std::string path) auto filedata = fload(path); const u8 *head = filedata.data(); - using fs::filesystem_t; - if(filesystem_t::r32b(head+0x00) == 0x00051607 && - filesystem_t::r32b(head+0x04) == 0x00020000) { - u16 nent = filesystem_t::r16b(head+0x18); + if(get_u32be(head+0x00) == 0x00051607 && + get_u32be(head+0x04) == 0x00020000) { + u16 nent = get_u16be(head+0x18); for(u16 i=0; i != nent; i++) { const u8 *e = head + 12*i; - if(filesystem_t::r32b(e+0) == 2) { - u32 start = filesystem_t::r32b(e+4); - u32 len = filesystem_t::r32b(e+8); + if(get_u32be(e+0) == 2) { + u32 start = get_u32be(e+4); + u32 len = get_u32be(e+8); filedata.erase(filedata.begin(), filedata.begin() + start); filedata.erase(filedata.begin() + len, filedata.end()); return filedata; @@ -194,14 +194,13 @@ void image_handler::fsave_rsrc(std::string path, const std::vector<u8> &data) { u8 head[0x2a]; - using fs::filesystem_t; - filesystem_t::w32b(head+0x00, 0x00051607); // Magic - filesystem_t::w32b(head+0x04, 0x00020000); // Version - filesystem_t::fill(head+0x08, 0, 16); // Filler - filesystem_t::w16b(head+0x18, 1); // Number of entries - filesystem_t::w32b(head+0x1a, 2); // Resource fork - filesystem_t::w32b(head+0x22, 0x2a); // Offset in the file - filesystem_t::w32b(head+0x26, data.size()); // Length + put_u32be(head+0x00, 0x00051607); // Magic + put_u32be(head+0x04, 0x00020000); // Version + memset(head+0x08, 0, 16); // Filler + put_u16be(head+0x18, 1); // Number of entries + put_u32be(head+0x1a, 2); // Resource fork + put_u32be(head+0x22, 0x2a); // Offset in the file + put_u32be(head+0x26, data.size()); // Length auto fo = fopen(path.c_str(), "wb"); if(!fo) { |