MCPcopy Create free account
hub / github.com/cjcliffe/CubicSDR / getOutputFileName

Method getOutputFileName

src/audio/AudioFile.cpp:16–45  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

14}
15
16std::string AudioFile::getOutputFileName() {
17
18 std::string recPath = wxGetApp().getConfig()->getRecordingPath();
19
20 // Strip any invalid characters from the name
21 std::string stripChars("<>:\"/\\|?*");
22 std::string filenameBaseSafe = filenameBase;
23
24 for (size_t i = 0, iMax = filenameBaseSafe.length(); i < iMax; i++) {
25 if (stripChars.find(filenameBaseSafe[i]) != std::string::npos) {
26 filenameBaseSafe.replace(i,1,"_");
27 }
28 }
29
30 // Create output file name
31 std::stringstream outputFileName;
32 outputFileName << recPath << filePathSeparator << filenameBaseSafe;
33
34 int idx = 0;
35
36 // If the file exists; then find the next non-existing file in sequence.
37 std::string fileNameCandidate = outputFileName.str();
38
39 while (FILE *file = fopen((fileNameCandidate + "." + getExtension()).c_str(), "r")) {
40 fclose(file);
41 fileNameCandidate = outputFileName.str() + "-" + std::to_string(++idx);
42 }
43
44 return fileNameCandidate + "." + getExtension();
45}
46

Callers

nothing calls this directly

Calls 5

getRecordingPathMethod · 0.80
getConfigMethod · 0.80
findMethod · 0.80
c_strMethod · 0.80
lengthMethod · 0.45

Tested by

no test coverage detected