mirror of
https://github.com/dolphin-emu/dolphin.git
synced 2025-07-21 05:09:34 -06:00
DolphinTool: Sensible changes
This commit is contained in:
@ -13,29 +13,29 @@ namespace DolphinTool
|
||||
{
|
||||
int HeaderCommand::Main(const std::vector<std::string>& args)
|
||||
{
|
||||
auto parser = std::make_unique<optparse::OptionParser>();
|
||||
optparse::OptionParser parser;
|
||||
|
||||
parser->usage("usage: header [options]...");
|
||||
parser.usage("usage: header [options]...");
|
||||
|
||||
parser->add_option("-i", "--input")
|
||||
parser.add_option("-i", "--input")
|
||||
.type("string")
|
||||
.action("store")
|
||||
.help("Path to disc image FILE.")
|
||||
.metavar("FILE");
|
||||
|
||||
parser->add_option("-b", "--block_size")
|
||||
parser.add_option("-b", "--block_size")
|
||||
.action("store_true")
|
||||
.help("Optional. Print the block size of GCZ/WIA/RVZ formats, then exit.");
|
||||
|
||||
parser->add_option("-c", "--compression")
|
||||
parser.add_option("-c", "--compression")
|
||||
.action("store_true")
|
||||
.help("Optional. Print the compression method of GCZ/WIA/RVZ formats, then exit.");
|
||||
|
||||
parser->add_option("-l", "--compression_level")
|
||||
parser.add_option("-l", "--compression_level")
|
||||
.action("store_true")
|
||||
.help("Optional. Print the level of compression for WIA/RVZ formats, then exit.");
|
||||
|
||||
const optparse::Values& options = parser->parse_args(args);
|
||||
const optparse::Values& options = parser.parse_args(args);
|
||||
|
||||
// Validate options
|
||||
const std::string input_file_path = static_cast<const char*>(options.get("input"));
|
||||
@ -45,18 +45,17 @@ int HeaderCommand::Main(const std::vector<std::string>& args)
|
||||
return 1;
|
||||
}
|
||||
|
||||
bool enable_block_size = options.is_set_by_user("block_size");
|
||||
bool enable_compression_method = options.is_set_by_user("compression");
|
||||
bool enable_compression_level = options.is_set_by_user("compression_level");
|
||||
const bool enable_block_size = options.is_set_by_user("block_size");
|
||||
const bool enable_compression_method = options.is_set_by_user("compression");
|
||||
const bool enable_compression_level = options.is_set_by_user("compression_level");
|
||||
|
||||
// Open the blob reader, plus get blob type
|
||||
std::shared_ptr<DiscIO::BlobReader> blob_reader = DiscIO::CreateBlobReader(input_file_path);
|
||||
const std::unique_ptr<DiscIO::BlobReader> blob_reader = DiscIO::CreateBlobReader(input_file_path);
|
||||
if (!blob_reader)
|
||||
{
|
||||
std::cerr << "Error: Unable to open disc image" << std::endl;
|
||||
return 1;
|
||||
}
|
||||
const DiscIO::BlobType blob_type = blob_reader->GetBlobType();
|
||||
|
||||
if (enable_block_size || enable_compression_method || enable_compression_level)
|
||||
{
|
||||
@ -87,6 +86,7 @@ int HeaderCommand::Main(const std::vector<std::string>& args)
|
||||
}
|
||||
else
|
||||
{
|
||||
const auto blob_type = blob_reader->GetBlobType();
|
||||
if (blob_type == DiscIO::BlobType::GCZ)
|
||||
{
|
||||
std::cout << "Block Size: " << blob_reader->GetBlockSize() << std::endl;
|
||||
@ -102,5 +102,4 @@ int HeaderCommand::Main(const std::vector<std::string>& args)
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
} // namespace DolphinTool
|
||||
|
Reference in New Issue
Block a user