mirror of
https://github.com/davidgiven/fluxengine.git
synced 2025-10-31 11:17:01 -07:00
Replace the Error() object with an error() function which takes fmt
formatspecs, making for much cleaner code. Reformatted everything. This actually happened in multiple steps but then I corrupted my local repository and I had to recover from the working tree.
This commit is contained in:
@@ -7,7 +7,8 @@ static std::fstream inputFile;
|
||||
void syntax()
|
||||
{
|
||||
std::cout << "Syntax: brother240tool <image>\n"
|
||||
"The disk image will be flipped from Brother to DOS format and back\n"
|
||||
"The disk image will be flipped from Brother to DOS format "
|
||||
"and back\n"
|
||||
"again.\n";
|
||||
exit(0);
|
||||
}
|
||||
@@ -26,39 +27,39 @@ void putbyte(uint32_t offset, uint8_t value)
|
||||
|
||||
int main(int argc, const char* argv[])
|
||||
{
|
||||
try
|
||||
{
|
||||
if (argc < 2)
|
||||
syntax();
|
||||
|
||||
inputFile.open(argv[1], std::ios::in | std::ios::out | std::ios::binary);
|
||||
if (!inputFile.is_open())
|
||||
Error() << fmt::format("cannot open input file '{}'", argv[1]);
|
||||
try
|
||||
{
|
||||
if (argc < 2)
|
||||
syntax();
|
||||
|
||||
uint8_t b1 = getbyte(0x015);
|
||||
uint8_t b2 = getbyte(0x100);
|
||||
if ((b1 == 0x58) && (b2 == 0x58))
|
||||
{
|
||||
std::cerr << "Flipping from Brother to DOS.\n";
|
||||
putbyte(0x015, 0xf0);
|
||||
putbyte(0x100, 0xf0);
|
||||
}
|
||||
else if ((b1 == 0xf0) && (b2 == 0xf0))
|
||||
{
|
||||
std::cerr << "Flipping from DOS to Brother.\n";
|
||||
putbyte(0x015, 0x58);
|
||||
putbyte(0x100, 0x58);
|
||||
}
|
||||
else
|
||||
Error() << "Unknown image format.";
|
||||
inputFile.open(
|
||||
argv[1], std::ios::in | std::ios::out | std::ios::binary);
|
||||
if (!inputFile.is_open())
|
||||
error("cannot open input file '{}'", argv[1]);
|
||||
|
||||
inputFile.close();
|
||||
return 0;
|
||||
}
|
||||
catch (const ErrorException& e)
|
||||
{
|
||||
e.print();
|
||||
exit(1);
|
||||
}
|
||||
uint8_t b1 = getbyte(0x015);
|
||||
uint8_t b2 = getbyte(0x100);
|
||||
if ((b1 == 0x58) && (b2 == 0x58))
|
||||
{
|
||||
std::cerr << "Flipping from Brother to DOS.\n";
|
||||
putbyte(0x015, 0xf0);
|
||||
putbyte(0x100, 0xf0);
|
||||
}
|
||||
else if ((b1 == 0xf0) && (b2 == 0xf0))
|
||||
{
|
||||
std::cerr << "Flipping from DOS to Brother.\n";
|
||||
putbyte(0x015, 0x58);
|
||||
putbyte(0x100, 0x58);
|
||||
}
|
||||
else
|
||||
error("Unknown image format.");
|
||||
|
||||
inputFile.close();
|
||||
return 0;
|
||||
}
|
||||
catch (const ErrorException& e)
|
||||
{
|
||||
e.print();
|
||||
exit(1);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user