[rpcli] rpcli.cpp: Un-indent a few functions.

- DoFile()
- DoScsiInquiry()
- DoAtaIdentifyDevice()

TODO: Return error codes if these functions fail?
This commit is contained in:
David Korth 2023-08-17 23:55:16 -04:00
parent 118b66c1d4
commit 837315505e

View File

@ -209,28 +209,29 @@ static void DoFile(const TCHAR *filename, bool json, const vector<ExtractParam>&
// FIXME: Make T2U8c() unnecessary here.
cerr << "== " << rp_sprintf(C_("rpcli", "Reading file '%s'..."), T2U8c(filename)) << endl;
RpFile *const file = new RpFile(filename, RpFile::FM_OPEN_READ_GZ);
if (file->isOpen()) {
RomData *romData = RomDataFactory::create(file);
if (romData && romData->isValid()) {
if (json) {
cerr << "-- " << C_("rpcli", "Outputting JSON data") << endl;
cout << JSONROMOutput(romData, lc, flags) << endl;
} else {
cout << ROMOutput(romData, lc, flags) << endl;
}
ExtractImages(romData, extract);
} else {
cerr << "-- " << C_("rpcli", "ROM is not supported") << endl;
if (json) cout << "{\"error\":\"rom is not supported\"}" << endl;
}
UNREF(romData);
} else {
if (!file->isOpen()) {
// TODO: Return an error code?
cerr << "-- " << rp_sprintf(C_("rpcli", "Couldn't open file: %s"), strerror(file->lastError())) << endl;
if (json) cout << "{\"error\":\"couldn't open file\",\"code\":" << file->lastError() << '}' << endl;
file->unref();
return;
}
RomData *const romData = RomDataFactory::create(file);
file->unref();
if (romData && romData->isValid()) {
if (json) {
cerr << "-- " << C_("rpcli", "Outputting JSON data") << endl;
cout << JSONROMOutput(romData, lc, flags) << endl;
} else {
cout << ROMOutput(romData, lc, flags) << endl;
}
ExtractImages(romData, extract);
} else {
cerr << "-- " << C_("rpcli", "ROM is not supported") << endl;
if (json) cout << "{\"error\":\"rom is not supported\"}" << endl;
}
UNREF(romData);
}
/**
@ -298,23 +299,29 @@ static void DoScsiInquiry(const TCHAR *filename, bool json)
// FIXME: Make T2U8c() unnecessary here.
cerr << "== " << rp_sprintf(C_("rpcli", "Opening device file '%s'..."), T2U8c(filename)) << endl;
RpFile *const file = new RpFile(filename, RpFile::FM_OPEN_READ_GZ);
if (file->isOpen()) {
// TODO: Check for unsupported devices? (Only CD-ROM is supported.)
if (file->isDevice()) {
if (json) {
cerr << "-- " << C_("rpcli", "Outputting JSON data") << endl;
// TODO: JSONScsiInquiry
//cout << JSONScsiInquiry(file) << endl;
} else {
cout << ScsiInquiry(file) << endl;
}
} else {
cerr << "-- " << C_("rpcli", "Not a device file") << endl;
if (json) cout << "{\"error\":\"Not a device file\"}" << endl;
}
} else {
if (!file->isOpen()) {
// TODO: Return an error code?
cerr << "-- " << rp_sprintf(C_("rpcli", "Couldn't open file: %s"), strerror(file->lastError())) << endl;
if (json) cout << "{\"error\":\"couldn't open file\",\"code\":" << file->lastError() << '}' << endl;
file->unref();
return;
}
// TODO: Check for unsupported devices? (Only CD-ROM is supported.)
if (file->isDevice()) {
// TODO: Return an error code?
cerr << "-- " << C_("rpcli", "Not a device file") << endl;
if (json) cout << "{\"error\":\"Not a device file\"}" << endl;
file->unref();
return;
}
if (json) {
cerr << "-- " << C_("rpcli", "Outputting JSON data") << endl;
// TODO: JSONScsiInquiry
//cout << JSONScsiInquiry(file) << endl;
} else {
cout << ScsiInquiry(file) << endl;
}
file->unref();
}
@ -330,23 +337,29 @@ static void DoAtaIdentifyDevice(const TCHAR *filename, bool json, bool packet)
// FIXME: Make T2U8c() unnecessary here.
cerr << "== " << rp_sprintf(C_("rpcli", "Opening device file '%s'..."), T2U8c(filename)) << endl;
RpFile *const file = new RpFile(filename, RpFile::FM_OPEN_READ_GZ);
if (file->isOpen()) {
// TODO: Check for unsupported devices? (Only CD-ROM is supported.)
if (file->isDevice()) {
if (json) {
cerr << "-- " << C_("rpcli", "Outputting JSON data") << endl;
// TODO: JSONAtaIdentifyDevice
//cout << JSONAtaIdentifyDevice(file) << endl;
} else {
cout << AtaIdentifyDevice(file, packet) << endl;
}
} else {
cerr << "-- " << C_("rpcli", "Not a device file") << endl;
if (json) cout << "{\"error\":\"Not a device file\"}" << endl;
}
} else {
if (!file->isOpen()) {
// TODO: Return an error code?
cerr << "-- " << rp_sprintf(C_("rpcli", "Couldn't open file: %s"), strerror(file->lastError())) << endl;
if (json) cout << "{\"error\":\"couldn't open file\",\"code\":" << file->lastError() << '}' << endl;
file->unref();
return;
}
// TODO: Check for unsupported devices? (Only CD-ROM is supported.)
if (!file->isDevice()) {
// TODO: Return an error code?
cerr << "-- " << C_("rpcli", "Not a device file") << endl;
if (json) cout << "{\"error\":\"Not a device file\"}" << endl;
file->unref();
return;
}
if (json) {
cerr << "-- " << C_("rpcli", "Outputting JSON data") << endl;
// TODO: JSONAtaIdentifyDevice
//cout << JSONAtaIdentifyDevice(file) << endl;
} else {
cout << AtaIdentifyDevice(file, packet) << endl;
}
file->unref();
}