| 183 | } |
| 184 | |
| 185 | std::string AudioFileWAV::getOutputFileName() { |
| 186 | |
| 187 | std::string recPath = wxGetApp().getConfig()->getRecordingPath(); |
| 188 | |
| 189 | // Strip any invalid characters from the name |
| 190 | std::string stripChars("<>:\"/\\|?*"); |
| 191 | std::string filenameBaseSafe = filenameBase; |
| 192 | |
| 193 | for (size_t i = 0, iMax = filenameBaseSafe.length(); i < iMax; i++) { |
| 194 | if (stripChars.find(filenameBaseSafe[i]) != std::string::npos) { |
| 195 | filenameBaseSafe.replace(i, 1, "_"); |
| 196 | } |
| 197 | } |
| 198 | |
| 199 | // Create output file name |
| 200 | std::stringstream outputFileName; |
| 201 | outputFileName << recPath << filePathSeparator << filenameBaseSafe; |
| 202 | |
| 203 | //customized part: append a sequence number. |
| 204 | if (currentSequenceNumber > 0) { |
| 205 | outputFileName << "_" << std::setfill('0') << std::setw(3) << currentSequenceNumber; |
| 206 | } |
| 207 | |
| 208 | int idx = 0; |
| 209 | |
| 210 | // If the file exists; then find the next non-existing file in sequence. |
| 211 | std::string fileNameCandidate = outputFileName.str(); |
| 212 | |
| 213 | while (FILE *file = fopen((fileNameCandidate + "." + getExtension()).c_str(), "r")) { |
| 214 | fclose(file); |
| 215 | fileNameCandidate = outputFileName.str() + "-" + std::to_string(++idx); |
| 216 | } |
| 217 | |
| 218 | return fileNameCandidate + "." + getExtension(); |
| 219 | } |
nothing calls this directly
no test coverage detected