replace file extension of input_file with new extension (with or without leading '.')
| 467 | |
| 468 | // replace file extension of input_file with new extension (with or without leading '.') |
| 469 | std::string FileExtSet(std::string fn_in, std::string ext_new) { |
| 470 | if (!ext_new.empty() && (ext_new[0] != '.')) ext_new = '.' + ext_new; |
| 471 | size_t pos = fn_in.find_last_of('.'); |
| 472 | if (pos == std::string::npos) { |
| 473 | return fn_in + ext_new; |
| 474 | } else { |
| 475 | return fn_in.substr(0, pos) + ext_new; |
| 476 | } |
| 477 | } |
| 478 | |
| 479 | /// Returns the extension of the file |
| 480 | std::string getFileExtension(const char* filepath) { |