Skip to content

Commit 578558c

Browse files
committed
chdman: Treat --split without a %t format variable in the output filename as an error
1 parent e1e9d43 commit 578558c

File tree

1 file changed

+9
-0
lines changed

1 file changed

+9
-0
lines changed

src/tools/chdman.cpp

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2644,6 +2644,7 @@ static void do_extract_cd(parameters_map &params)
26442644
std::string::const_iterator new_trackbin_name_end = new_trackbin_name.end();
26452645
std::string filename_formatted = new_trackbin_name;
26462646
std::smatch variable_matches;
2647+
bool found_track_variable = false;
26472648

26482649
while (std::regex_search(new_trackbin_name_itr, new_trackbin_name_end, variable_matches, variables_regex))
26492650
{
@@ -2662,7 +2663,10 @@ static void do_extract_cd(parameters_map &params)
26622663
{
26632664
// track number
26642665
if (is_splitbin)
2666+
{
26652667
replacement = util::string_format("%" + format_part + "d", tracknum+1);
2668+
found_track_variable = true;
2669+
}
26662670
}
26672671
else
26682672
{
@@ -2681,6 +2685,11 @@ static void do_extract_cd(parameters_map &params)
26812685
new_trackbin_name_itr = variable_matches.suffix().first; // move past match for next loop
26822686
}
26832687

2688+
if (is_splitbin && !found_track_variable)
2689+
{
2690+
report_error(1, "A track number variable (%%t) must be specified in the output bin filename when --%s is enabled\n", OPTION_OUTPUT_SPLIT);
2691+
}
2692+
26842693
// verify output BIN file doesn't exist
26852694
check_existing_output_file(params, filename_formatted);
26862695

0 commit comments

Comments
 (0)