Create unique name for the temporary file @output: - QString - string with the absolute path to the temporary file that is not exist yet. If function failed to create unique path, it will return empty string.
| 161 | // exist yet. If function failed to create unique path, it will return empty |
| 162 | // string. |
| 163 | QString WriterPrivate::getTempFileName() |
| 164 | { |
| 165 | const auto nameTemplate = QDir::tempPath() + "/qtcsv_" + |
| 166 | QString::number(QCoreApplication::applicationPid()) + "_%1.csv"; |
| 167 | |
| 168 | for (auto counter = 0; counter < std::numeric_limits<int>::max(); ++counter) |
| 169 | { |
| 170 | QString name = nameTemplate.arg( |
| 171 | QString::number(QRandomGenerator::global()->generate())); |
| 172 | |
| 173 | if (!QFile::exists(name)) { return name; } |
| 174 | } |
| 175 | |
| 176 | return QString(); |
| 177 | } |
| 178 | |
| 179 | // Write data to csv-file |
| 180 | // @input: |