MCPcopy Create free account
hub / github.com/KangLin/RabbitRemoteControl / ExportFileToJson

Method ExportFileToJson

Src/Database/Database.cpp:657–684  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

655}
656
657bool CDatabaseFile::ExportFileToJson(const QString &szFile, QJsonObject &obj)
658{
659 QString szErr;
660 QFileInfo fi(szFile);
661 if(fi.isRelative()) {
662 fi = QFileInfo(SetFile(szFile));
663 }
664 if(!fi.exists()) {
665 szErr = "File is not exist: " + fi.filePath();
666 qCritical(log) << szErr;
667 return false;
668 }
669 QFile f(fi.absoluteFilePath());
670 if(!f.open(QFile::ReadOnly | QFile::Text)) {
671 szErr = "Failed to open file: " + f.fileName() + "; Error: " + f.errorString();
672 qCritical(log) << szErr;
673 return false;
674 }
675 QString szFileContent = f.readAll();
676 f.close();
677 if(szFileContent.isEmpty()) {
678 qCritical(log) << "The file is empty:" << szFile;
679 return false;
680 };
681 obj.insert("FileName", fi.fileName());
682 obj.insert("FileContent", szFileContent);
683 return true;
684}
685
686bool CDatabaseFile::ImportFileFromJson(const QJsonObject &obj, QString &szFile)
687{

Callers

nothing calls this directly

Calls 4

errorStringMethod · 0.80
openMethod · 0.45
closeMethod · 0.45
isEmptyMethod · 0.45

Tested by

no test coverage detected