summaryrefslogtreecommitdiffstatshomepage
path: root/src/tools/image_handler.cpp
diff options
context:
space:
mode:
author AJR <ajrhacker@users.noreply.github.com>2023-02-16 20:19:51 -0500
committer AJR <ajrhacker@users.noreply.github.com>2023-02-16 20:19:51 -0500
commit58156cf7dc315edc6573cea158422edb48521bd0 (patch)
tree3a6622dcc031a17dd8579948e8b1e09804166f6e /src/tools/image_handler.cpp
parent3d532402e5d58312a81d8e01600f67ca66b5d413 (diff)
image_handler.cpp: Eliminate use of sprintf for error messages
Diffstat (limited to 'src/tools/image_handler.cpp')
-rw-r--r--src/tools/image_handler.cpp12
1 files changed, 3 insertions, 9 deletions
diff --git a/src/tools/image_handler.cpp b/src/tools/image_handler.cpp
index 44d7fce7df3..a2083bcbd59 100644
--- a/src/tools/image_handler.cpp
+++ b/src/tools/image_handler.cpp
@@ -139,11 +139,9 @@ const floppy_create_info *formats_table::find_floppy_create_info_by_key(const st
std::vector<u8> image_handler::fload(std::string path)
{
- char msg[4096];
- sprintf(msg, "Error opening %s for reading", path.c_str());
auto fi = fopen(path.c_str(), "rb");
if(!fi) {
- perror(msg);
+ perror(util::string_format("Error opening %s for reading", path).c_str());
exit(1);
}
fseek(fi, 0, SEEK_END);
@@ -182,11 +180,9 @@ std::vector<u8> image_handler::fload_rsrc(std::string path)
void image_handler::fsave(std::string path, const std::vector<u8> &data)
{
- char msg[4096];
- sprintf(msg, "Error opening %s for writing", path.c_str());
auto fo = fopen(path.c_str(), "wb");
if(!fo) {
- perror(msg);
+ perror(util::string_format("Error opening %s for writing", path).c_str());
exit(1);
}
@@ -207,11 +203,9 @@ void image_handler::fsave_rsrc(std::string path, const std::vector<u8> &data)
filesystem_t::w32b(head+0x22, 0x2a); // Offset in the file
filesystem_t::w32b(head+0x26, data.size()); // Length
- char msg[4096];
- sprintf(msg, "Error opening %s for writing", path.c_str());
auto fo = fopen(path.c_str(), "wb");
if(!fo) {
- perror(msg);
+ perror(util::string_format("Error opening %s for writing", path).c_str());
exit(1);
}