| 140 | } |
| 141 | |
| 142 | void changeFilename(const std::string& filename) |
| 143 | { |
| 144 | static std::regex FORMATTER("(?:(1?[0-9]):)?([^ .]+)\\.?([^ .]*)"); |
| 145 | std::smatch results; |
| 146 | bool matched = std::regex_match(filename, results, FORMATTER); |
| 147 | if (!matched) |
| 148 | throw BadPathException(); |
| 149 | |
| 150 | std::string user = results[1]; |
| 151 | std::string stem = results[2]; |
| 152 | std::string ext = results[3]; |
| 153 | |
| 154 | if (stem.size() > 8) |
| 155 | throw BadPathException(); |
| 156 | if (ext.size() > 3) |
| 157 | throw BadPathException(); |
| 158 | |
| 159 | this->user = std::stoi(user); |
| 160 | if (this->user > 15) |
| 161 | throw BadPathException(); |
| 162 | |
| 163 | if (ext.empty()) |
| 164 | this->filename = stem; |
| 165 | else |
| 166 | this->filename = fmt::format("{}.{}", stem, ext); |
| 167 | } |
| 168 | |
| 169 | std::string combinedFilename() const |
| 170 | { |
no test coverage detected