MCPcopy Create free account
hub / github.com/altairwei/WizNotePlus / loadCompressedAttachmentData

Method loadCompressedAttachmentData

src/database/WizDatabase.cpp:4215–4251  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

4213}
4214
4215bool WizDatabase::loadCompressedAttachmentData(const QString& strGUID, QByteArray& arrayData)
4216{
4217 CString strFileName = getAttachmentFileName(strGUID);
4218 if (!WizPathFileExists(strFileName))
4219 {
4220 return false;
4221 }
4222 CString strTempZipFileName = Utils::WizPathResolve::tempPath() + WizIntToStr(WizGetTickCount()) + ".tmp";
4223 WizZipFile zip;
4224 if (!zip.open(strTempZipFileName))
4225 {
4226 Q_EMIT updateError("Failed to create temp zip file: " + strTempZipFileName);
4227 return false;
4228 }
4229
4230 WIZDOCUMENTATTACHMENTDATA attach;
4231 attachmentFromGuid(strGUID, attach);
4232 if (!zip.compressFile(strFileName, attach.strName))
4233 {
4234 Q_EMIT updateError("Failed to compress file: " + strFileName);
4235 return false;
4236 }
4237
4238 zip.close();
4239
4240 QFile file(strTempZipFileName);
4241 if (!file.open(QFile::ReadOnly))
4242 return false;
4243
4244 arrayData = file.readAll();
4245 //
4246 file.close();
4247 //
4248 QFile::remove(strTempZipFileName);
4249
4250 return !arrayData.isEmpty();
4251}
4252
4253bool WizDatabase::saveCompressedAttachmentData(const CString& strGUID, const QByteArray& arrayData)
4254{

Callers

nothing calls this directly

Calls 7

WizPathFileExistsFunction · 0.85
WizIntToStrFunction · 0.85
WizGetTickCountFunction · 0.85
compressFileMethod · 0.80
isEmptyMethod · 0.80
openMethod · 0.45
closeMethod · 0.45

Tested by

no test coverage detected