| 684 | } |
| 685 | |
| 686 | bool CDatabaseFile::ImportFileFromJson(const QJsonObject &obj, QString &szFile) |
| 687 | { |
| 688 | QString szErr; |
| 689 | QString szFileContent = obj["FileContent"].toString(); |
| 690 | if(szFileContent.isEmpty()) { |
| 691 | qCritical(log) << "The file content is empty."; |
| 692 | return false; |
| 693 | } |
| 694 | szFile = obj["FileName"].toString(); |
| 695 | if(szFile.isEmpty()) { |
| 696 | qCritical(log) << "The file name is empty."; |
| 697 | return false; |
| 698 | } |
| 699 | szFile = GetFile(szFile); |
| 700 | QFileInfo fi(szFile); |
| 701 | if(!fi.exists()) { |
| 702 | QFile f(szFile); |
| 703 | if(!f.open(QFile::WriteOnly | QFile::Text)) { |
| 704 | szErr = "Failed to open file: " + szFile |
| 705 | + "; Error: " + f.errorString(); |
| 706 | qCritical(log) << szErr; |
| 707 | return false; |
| 708 | } |
| 709 | f.write(szFileContent.toStdString().c_str(), szFileContent.size()); |
| 710 | f.close(); |
| 711 | } |
| 712 | return true; |
| 713 | } |
| 714 | |
| 715 | bool CDatabaseFile::ImportFileToDatabaseFromJson(const QJsonObject &obj, QString &szFile) |
| 716 | { |
nothing calls this directly
no test coverage detected