Overall, good code. There is a trap code fell into though.
while (!input.eof())
One of the frequently encountered problems with iostreams. Check the output if it has one extra newline. I'm sure you'll find it. intput.eof() is true when EOF is read, not before it.
Instead, use stream >> variable as a condition or the function that behaves like that. The expression returns a reference to stream itself, but the stream is convertible to bool to see if some failure occured. Basically, the expression above is all these steps:
- Try to read.
- Set failure flags if error encountered
- Return the status
Put in a condition, it is the exact combination one needs to perform more or less controlled input. One needs to check if the read succeeded before doing anything. Some other functions in standard library behave like operator>>, std::getline() included.
As a result of above, the first line of the loop would just become a condition, and everything else intact.
while (std::getline(input, in)) {
output << std::regex_replace(in, pattern, "($1 * resize.x) + pos.x, ($3 * resize.y) + pos.y")
<< '\n';
}
Smaller things follow.
Usage message would be nice. Usually frequently used utilities are put away from the code. Though in case of single argument programs it might not be much of a problem.
std::ofstream output(path.substr(found_name + 1, steps) + ".txt");
Is a little bit alerting. Since this is end user program (e.g. for a human), they might get something wrong.
Some missing consts here and there.
return 0 is redundant.