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.
| 177 | // exist yet. If function failed to create unique path, it will return empty |
| 178 | // string. |
| 179 | QString WriterPrivate::getTempFileName() |
| 180 | { |
| 181 | QString nameTemplate = QDir::tempPath() + "/qtcsv_" + |
| 182 | QString::number(QCoreApplication::applicationPid()) + "_%1.csv"; |
| 183 | |
| 184 | for (int counter = 0; counter < std::numeric_limits<int>::max(); ++counter) |
| 185 | { |
| 186 | #if (QT_VERSION >= QT_VERSION_CHECK(5, 10, 0)) |
| 187 | QString name = nameTemplate.arg( |
| 188 | QString::number(QRandomGenerator::global()->generate())); |
| 189 | #else |
| 190 | QString name = nameTemplate.arg(QString::number(qrand())); |
| 191 | #endif |
| 192 | if (false == QFile::exists(name)) { return name; } |
| 193 | } |
| 194 | |
| 195 | return QString(); |
| 196 | } |
| 197 | |
| 198 | // Write data to csv-file |
| 199 | // @input: |