std::map<std::string, std::string> jsonValueToAccount(Json::Value& value, const std::string& accountId) { auto idPath_ = fileutils::get_data_dir() + DIR_SEPARATOR_STR + accountId; fileutils::check_dir(idPath_.c_str(), 0700); auto detailsMap = DRing::getAccountTemplate(value[DRing::Account::ConfProperties::TYPE].asString()); for( Json::ValueIterator itr = value.begin() ; itr != value.end() ; itr++ ) { if (itr->asString().empty()) continue; if (itr.key().asString().compare(DRing::Account::ConfProperties::TLS::CA_LIST_FILE) == 0) { std::string fileContent(itr->asString()); fileutils::saveFile(idPath_ + DIR_SEPARATOR_STR "ca.key", {fileContent.begin(), fileContent.end()}, 0600); } else if (itr.key().asString().compare(DRing::Account::ConfProperties::TLS::PRIVATE_KEY_FILE) == 0) { std::string fileContent(itr->asString()); fileutils::saveFile(idPath_ + DIR_SEPARATOR_STR "dht.key", {fileContent.begin(), fileContent.end()}, 0600); } else if (itr.key().asString().compare(DRing::Account::ConfProperties::TLS::CERTIFICATE_FILE) == 0) { std::string fileContent(itr->asString()); fileutils::saveFile(idPath_ + DIR_SEPARATOR_STR "dht.crt", {fileContent.begin(), fileContent.end()}, 0600); } else detailsMap[itr.key().asString()] = itr->asString(); } return detailsMap; }
bool ListUpdater::compareHashes() { // compare new hash with current hash QString localHash = fileContent(m_md5FileMap[m_listType]); QString serverHash = fileContent(QString(m_md5FileMap[m_listType]).prepend(SERVER_FILE_PREFIX)); if (localHash == serverHash) return true; return false; // HASH NOT MATCH }
// read keywords from files, initialize structure Keys with keyword and 0 int InitKeys(std::string fileName, const std::string splitString, KeysList& keysList) { std::fstream fsRead; fsRead.open(fileName.c_str(), std::fstream::in); if (!fsRead) { return 10; } keysList.clear(); // read all contents of file once std::stringstream ssBuffer; ssBuffer << fsRead.rdbuf(); std::string fileContent(ssBuffer.str()); fsRead.close(); std::vector<std::string> vFunctions; vFunctions.clear(); boost::algorithm::split(vFunctions, fileContent, boost::algorithm::is_any_of(splitString.c_str())); std::vector<std::string>::iterator it; for (it = vFunctions.begin(); it != vFunctions.end(); ++it) { keysList.push_back(MakeKeys(fileName, *it)); } return 0; }
bool StatusThread::updateLog(QList<QFileInfo> listTXT, QDateTime& time) { QDateTime timeNew = QFileInfo(listTXT[0].absoluteFilePath()).lastModified(); if (timeNew == time) return false; qDebug() << ++i; time = timeNew; QFile file(listTXT[0].absoluteFilePath()); qDebug() << file.fileName(); if (!file.open(QIODevice::ReadOnly | QIODevice::Text)) return false; QTextStream out(&file); QString fileContent(out.readAll()); //emit textAppend2("\n"); //emit textAppend2("*************************************************"); //emit textAppend2("*********************UPDATE**********************"); //emit textAppend2("*************************************************"); //emit textAppend2("\n"); //emit textAppend2(fileContent); //emit textAppend1(fileContent); emit textAppend1(LogFileData::change(fileContent).join("\n")); emit textAppend1("\n"); emit textAppend1("*************************************************"); emit textAppend1("*********************UPDATE**********************"); emit textAppend1("*************************************************"); emit textAppend1("\n"); file.close(); return true; }
bool NemoCalendarImportModel::importFromFile(const QString &fileName, KCalCore::Calendar::Ptr calendar) { QString filePath; QUrl url(fileName); if (url.isLocalFile()) filePath = url.toLocalFile(); else filePath = fileName; if (!(filePath.endsWith(".vcs") || filePath.endsWith(".ics"))) { qWarning() << "Unsupported file format" << filePath; return false; } QFile file(filePath); if (!file.open(QIODevice::ReadOnly | QIODevice::Text)) { qWarning() << "Unable to open file for reading" << filePath; return false; } QString fileContent(file.readAll()); bool ok = false; if (filePath.endsWith(".vcs")) { KCalCore::VCalFormat vcalFormat; ok = vcalFormat.fromString(calendar, fileContent); } else if (filePath.endsWith(".ics")) { KCalCore::ICalFormat icalFormat; ok = icalFormat.fromString(calendar, fileContent); } if (!ok) qWarning() << "Failed to import from file" << filePath; return ok; }
int ImportCsvDialogue::save() { int num_failed = 0; ImportDialogueTableRow *row; foreach (QStringList values, fileContent()) { row = new ImportDialogueTableRow; int i; for (i = 0; i < current_table->count(); ++i) { int index = trw_columns->topLevelItem(i)->text(1).toInt() - 1; if (index < 0) continue; row->addValue(current_table->at(i), values.at(index)); } for (int n = 0; n < current_table->childTablesCount(); ++n) { for (int k = 0; k < current_table->childTableAt(n)->count(); ++k, ++i) { int index = trw_columns->topLevelItem(i)->text(1).toInt() - 1; if (index < 0) continue; row->addValue(current_table->childTableAt(n)->at(k), values.at(index)); } } if (!current_table->save(row)) num_failed++; delete row; }
void HTTPCallbackTcpConnection::handlePostRequest( const boost::system::error_code& error) { ifstream index(CROSS_SITE_CALLBACK_HTML); string fileContent((istreambuf_iterator<char>(index)), istreambuf_iterator<char>()); async_write(localSocket, buffer(fileContent), bind(&HTTPCallbackTcpConnection::handleWrite, shared_from_this(), placeholders::error)); }
bool kcVulkanStatisticsParser::ParseStatistics(const gtString& satisticsFilePath, beKA::AnalysisData& parsedStatistics) { bool ret = false; parsedStatistics.ISASize = 0; parsedStatistics.numSGPRsUsed = 0; parsedStatistics.numVGPRsUsed = 0; // Check if the file exists. if (!satisticsFilePath.isEmpty()) { osFilePath filePath(satisticsFilePath); if (filePath.exists()) { std::ifstream file(satisticsFilePath.asASCIICharArray()); std::string fileContent((std::istreambuf_iterator<char>(file)), std::istreambuf_iterator<char>()); if (!fileContent.empty()) { // Extract the ISA size in bytes. size_t isaSizeInBytes = 0; bool isIsaSizeExtracted = ExtractIsaSize(fileContent, isaSizeInBytes); if (isIsaSizeExtracted) { parsedStatistics.ISASize = isaSizeInBytes; } // Extract the number of used SGPRs. size_t usedSgprs = 0; bool isSgprsExtracted = ExtractUsedSgprs(fileContent, usedSgprs); if (isSgprsExtracted) { parsedStatistics.numSGPRsUsed = usedSgprs; } // Extract the number of used VGPRs. size_t usedVgprs = 0; bool isVgprsExtracted = ExtractUsedVgprs(fileContent, usedVgprs); if (isVgprsExtracted) { parsedStatistics.numVGPRsUsed = usedVgprs; } // We succeeded if all data was extracted successfully. ret = (isIsaSizeExtracted && isSgprsExtracted && isVgprsExtracted); } } } return ret; }
Font * FontLoader::loadFont(const char * path, float fontSize, int textureWidth, int textureHeight) { Font * font = 0; unsigned char * data; int length; if (fileContent(path, &data, length)) { font = new Font(); font->size = fontSize; unsigned char * alpha = new unsigned char[textureWidth * textureHeight]; stbtt_bakedchar charDef[96]; stbtt_BakeFontBitmap(data, 0, fontSize, alpha, textureWidth, textureHeight, 32, 96, charDef); delete[] data; // Construct an luminance-alpha texture unsigned char * image = new unsigned char[textureWidth * textureHeight * 2]; for (int i = 0, len = textureWidth * textureHeight; i < len; ++i) { image[i * 2 + 0] = 255; image[i * 2 + 1] = alpha[i]; } // Create the texture Texture * texture = new Texture(); texture->images[0] = image; texture->width = textureWidth; texture->height = textureHeight; texture->format = LuminanceAlphaFormat; texture->imageDataType = UnsignedByteType; texture->type = Texture2D; font->texture = texture; // Copy glyph info for (int i = 0; i < 96; ++i) { float x = 0.0f, y = 0.0f; Font::Glyph & glyph = font->glyphs[i]; stbtt_aligned_quad quad; stbtt_GetBakedQuad(charDef, textureWidth, textureHeight, i, &x, &y, &quad, 1); float offsetX = quad.x0 < 0.0f ? -quad.x0 : 0.0f; glyph.topLeft = Vector2(quad.x0 + offsetX, quad.y0); glyph.bottomRight = Vector2(quad.x1 + offsetX, quad.y1); glyph.uvTopLeft = Vector2(quad.s0, quad.t0); glyph.uvBottomRight = Vector2(quad.s1, quad.t1); glyph.advance = x; } } return font; }
void SceneImage::initialize() { AbstractGLScene::initialize(); m_texture = new QOpenGLTexture(m_tex.mirrored()); glClearColor(0, 0, 0, 0); if (!m_shader.addShaderFromSourceCode(QOpenGLShader::Vertex, fileContent("image.vert"))) qDebug() << "Failed to load vertex shader"; if (!m_shader.addShaderFromSourceCode(QOpenGLShader::Fragment, fileContent("image.frag"))) qDebug() << "Failed to load fragmanet shader"; m_shader.link(); m_shader.bind(); m_shader.setAttributeArray("qt_Vertex", GL_FLOAT, m_data.constData(), 3, sizeof(TexturedPoint)); m_shader.enableAttributeArray("qt_Vertex"); m_shader.setAttributeArray("qt_MultiTexCoord0", GL_FLOAT, &m_data[0].uv, 2, sizeof(TexturedPoint)); m_shader.enableAttributeArray("qt_MultiTexCoord0"); }
bool VShadingPass::Compile(const VFileList &vertexShaders, const VFileList &fragmShaders) { VString bigSourceStr; for( VFileList::const_iterator i = vertexShaders.begin(); i != vertexShaders.end(); ++i ) { const VString &fileName = *i; CPVRTResourceFile shaderFile(fileName.c_str()); if( !shaderFile.IsOpen() ) return false; VString fileContent((const char*) shaderFile.DataPtr(), shaderFile.Size()); bigSourceStr += fileContent; } if( !mVertexShader.Create(GL_VERTEX_SHADER, bigSourceStr.c_str(), &mErrorLog ) ) { return false; } bigSourceStr.clear(); for( VFileList::const_iterator i = fragmShaders.begin(); i != fragmShaders.end(); ++i ) { const VString &fileName = *i; CPVRTResourceFile shaderFile(fileName.c_str()); if( !shaderFile.IsOpen() ) return false; VString fileContent((const char*) shaderFile.DataPtr(), shaderFile.Size()); bigSourceStr += fileContent; } if( !mFragmentShader.Create(GL_FRAGMENT_SHADER, bigSourceStr.c_str(), &mErrorLog ) ) { return false; } return true; }
std::string readFile(const char* file) { std::ifstream fileContent(file, std::ios::in | std::ios::binary); std::string temp, buffer = ""; if (fileContent) { // Read file while (std::getline(fileContent, temp)) buffer.append(temp); // Close file fileContent.close(); } return buffer; }
// Parses the contents of a file, retrieves Transactions and appends them to an array void parseTransactionFile(std::vector<Transaction>& aTransactions, std::string fileName){ try{ std::string dummyField = ""; int fieldCount = 1; Transaction dummyT = Transaction("", 0, "", ""); std::ifstream tFile(fileName.c_str()); std::string fileContent((std::istreambuf_iterator<char>(tFile)) ,(std::istreambuf_iterator<char>())); if(fileContent.length() < 1 ) return; tFile.close(); // Close file and start working on the local string // Parse file to retrieve transactions std::istringstream ss(fileContent); std::string transactionString; // Holds the body of the transaction std::vector<std::string> allTransactions; while(std::getline(ss, transactionString,'#')){ allTransactions.push_back(transactionString); } // Now iterate on the tokens for(std::vector<std::string>::iterator it = allTransactions.begin(); it != allTransactions.end(); it++){ transactionString = *it; // Get transaction body std::istringstream ss(transactionString); int fieldCount = 1; std::string token; // Loop on transaction fields dummyT.setDesc("No description."); while(std::getline(ss, token, '\n')){ if(token.length() > 0){ if(fieldCount % 4 == 1) { dummyT.setReceiver(token); fieldCount +=1;} else if(fieldCount % 4 == 2) { dummyT.setToken(token); fieldCount +=1;} else if(fieldCount % 4 == 3) { dummyT.setAmount(atoi(token.c_str())); fieldCount +=1;} else if(fieldCount % 4 == 0){ dummyT.setDesc(token); } } } aTransactions.push_back(dummyT); } }catch(std::exception& e){ std::cout << "Error encountered: " << e.what() << std::endl; } }
/** * @brief Function that sends the multipart message request to the API server. * Shows the image being OCR'd in the left-hand side of the interface */ void MainWindow::recognize(){ QHttpMultiPart* multipart = new QHttpMultiPart(QHttpMultiPart::FormDataType); //set up http part message to send to api that contains image data QHttpPart imagePart; imagePart.setHeader(QNetworkRequest::ContentTypeHeader, QVariant("image/gif")); imagePart.setHeader(QNetworkRequest::ContentDispositionHeader, QVariant("form-data; name=\"file\"; filename=\"./Polish_test2.gif\"")); QFile* file = new QFile(fileName); //debugging: make sure file was uploaded if(!file->open(QIODevice::ReadOnly)){ qDebug() << "# Could not upload/open file"; } QByteArray fileContent(file->readAll()); imagePart.setBody(fileContent); //append image data, api key, language, and overlay setting to multipart multipart->append(imagePart); multipart->append(part_parameter("apikey","3653fc62e388957")); multipart->append(part_parameter("language","pol")); multipart->append(part_parameter("isOverlayRequired","false")); //ocr api url QUrl api_url("https://apifree2.ocr.space/parse/image"); //create network request obj that contains the api url QNetworkRequest api_request(api_url); manager = new QNetworkAccessManager; //=(url, multipart encoded message) reply = manager->post(api_request, multipart); QObject::connect(reply, SIGNAL(finished()), this, SLOT(networkData())); //debugging: make sure file was opened; if 0 bytes, it wasn't! qDebug() << file->size() << "bytes"; imagePart.setBodyDevice(file); file->setParent(multipart); networkData(); }
Json::Value accountToJsonValue(std::map<std::string, std::string> details) { Json::Value root; std::map<std::string, std::string>::iterator iter; for (iter = details.begin(); iter != details.end(); ++iter) { if (iter->first.compare(DRing::Account::ConfProperties::Ringtone::PATH) == 0) { // Ringtone path is not exportable } else if (iter->first.compare(DRing::Account::ConfProperties::TLS::CA_LIST_FILE) == 0 || iter->first.compare(DRing::Account::ConfProperties::TLS::CERTIFICATE_FILE) == 0 || iter->first.compare(DRing::Account::ConfProperties::TLS::PRIVATE_KEY_FILE) == 0) { // replace paths by the files content std::ifstream ifs(iter->second); std::string fileContent((std::istreambuf_iterator<char>(ifs)), std::istreambuf_iterator<char>()); root[iter->first] = fileContent; } else root[iter->first] = iter->second; } return root; }
std::unique_ptr<TriangleMesh> LoadTriangleMesh(const std::string& fileName) { enum { headerSize = 80, facetSize = 50, maxVerticesCount = static_cast<size_t>(std::numeric_limits<int32_t>::max()), maxTrianglesCount = static_cast<size_t>(std::numeric_limits<int32_t>::max()) }; struct VectorHash { std::size_t operator()(const Vector_f& v) const { size_t h1 = std::hash<float>()(v.x); size_t h2 = std::hash<float>()(v.y); size_t h3 = std::hash<float>()(v.z); return CombineHashes(h1, CombineHashes(h2, h3)); } }; std::ifstream file(fileName, std::ios_base::in | std::ios_base::binary); if (!file) RuntimeError("failed to open file: " + fileName); // get file size file.seekg(0, std::ios_base::end); auto fileSize = file.tellg(); file.seekg(0, std::ios_base::beg); if (fileSize == std::streampos(-1) || !file) RuntimeError("failed to read file stats: " + fileName); // read file content std::vector<uint8_t> fileContent(static_cast<size_t>(fileSize)); file.read(reinterpret_cast<char*>(fileContent.data()), fileSize); if (!file) RuntimeError("failed to read file content: " + fileName); // validate file content std::array<uint8_t, 5> asciiStlHeader = {0x73, 0x6f, 0x6c, 0x69, 0x64}; if (memcmp(fileContent.data(), asciiStlHeader.data(), 5) == 0) RuntimeError("ascii stl files are not supported: " + fileName); if (fileSize < headerSize + 4) RuntimeError("invalid binary stl file: " + fileName); uint32_t numTriangles = *reinterpret_cast<uint32_t*>(fileContent.data() + headerSize); if (numTriangles > maxTrianglesCount) RuntimeError("too large model: too many triangles: " + fileName); auto expectedSize = headerSize + 4 + static_cast<size_t>(numTriangles) * facetSize; if (fileContent.size() != expectedSize) RuntimeError("incorrect size of binary stl file: " + fileName); // read mesh data auto mesh = std::unique_ptr<TriangleMesh>(new TriangleMesh()); mesh->normals.resize(numTriangles); mesh->triangles.resize(numTriangles); std::unordered_map<Vector_f, int32_t, VectorHash> uniqueVertices; uint8_t* dataPtr = fileContent.data() + headerSize + 4; for (uint32_t i = 0; i < numTriangles; i++) { float* f = reinterpret_cast<float*>(dataPtr); mesh->normals[i] = Vector_f(f[0], f[1], f[2]); f += 3; for (int k = 0; k < 3; ++k) { Vector_f v(f[0], f[1], f[2]); f += 3; int32_t vertexIndex; auto iterator = uniqueVertices.find(v); if (iterator == uniqueVertices.cend()) { if (mesh->vertices.size() > maxVerticesCount) { RuntimeError("too large model: too many vertices"); } vertexIndex = static_cast<int32_t>(mesh->vertices.size()); uniqueVertices[v] = vertexIndex; mesh->vertices.push_back(v); } else { vertexIndex = iterator->second; } mesh->triangles[i].points[k].vertexIndex = vertexIndex; } dataPtr += facetSize; } std::vector<Vector_f>(mesh->vertices).swap(mesh->vertices); return mesh; }
void FileGathererThread::gatheringKernel(const boost::shared_ptr<FileSystemItem>& item) { QDir dir( item->absoluteFilePath() ); Qt::SortOrder viewOrder = _imp->model->sortIndicatorOrder(); FileSystemModel::Sections sortSection = (FileSystemModel::Sections)_imp->model->sortIndicatorSection(); switch (sortSection) { case FileSystemModel::Name: dir.setSorting(QDir::Name); break; case FileSystemModel::Size: dir.setSorting(QDir::Size); break; case FileSystemModel::Type: dir.setSorting(QDir::Type); break; case FileSystemModel::DateModified: dir.setSorting(QDir::Time); break; default: break; } ///All entries in the directory QFileInfoList all = dir.entryInfoList(_imp->model->filter()); ///List of all possible file sequences in the directory or directories FileSequences sequences; int start; int end; switch (viewOrder) { case Qt::AscendingOrder: start = 0; end = all.size(); break; case Qt::DescendingOrder: start = all.size() - 1; end = -1; break; } int i = start; while (i != end) { ///If we must abort we do it now if ( _imp->checkForAbort() ) { return; } if ( all[i].isDir() ) { ///This is a directory sequences.push_back(std::make_pair(boost::shared_ptr<SequenceParsing::SequenceFromFiles>(), all[i])); } else { QString filename = all[i].fileName(); /// If the item does not match the filter regexp set by the user, discard it if ( !_imp->model->isAcceptedByRegexps(filename) ) { KERNEL_INCR(); continue; } /// If file sequence fetching is disabled, accept it if ( !_imp->model->isSequenceModeEnabled() ) { sequences.push_back(std::make_pair(boost::shared_ptr<SequenceParsing::SequenceFromFiles>(), all[i])); KERNEL_INCR(); continue; } std::string absoluteFilePath = generateChildAbsoluteName(item.get(), filename).toStdString(); bool foundMatchingSequence = false; /// If we reach here, this is a valid file and we need to determine if it belongs to another sequence or we need /// to create a new one SequenceParsing::FileNameContent fileContent(absoluteFilePath); ///Note that we use a reverse iterator because we have more chance to find a match in the last recently added entries for (FileSequences::reverse_iterator it = sequences.rbegin(); it != sequences.rend(); ++it) { if ( it->first && it->first->tryInsertFile(fileContent,false) ) { foundMatchingSequence = true; break; } } if (!foundMatchingSequence) { boost::shared_ptr<SequenceParsing::SequenceFromFiles> newSequence( new SequenceParsing::SequenceFromFiles(fileContent,true) ); sequences.push_back(std::make_pair(newSequence, all[i])); } } KERNEL_INCR(); } ///Now iterate through the sequences and create the children as necessary for (FileSequences::iterator it = sequences.begin(); it != sequences.end(); ++it) { item->addChild(it->first, it->second); } emit directoryLoaded( item->absoluteFilePath() ); }
void CRecogStep::TestRecognizeDataL() { TDataRecognitionResult recogResult; TPtrC tmp; GetStringFromConfig(ConfigSection(), _L("fileName"), tmp); iFileName = tmp; TPtrC expectedDataType16; GetStringFromConfig(ConfigSection(), _L("expectedDataType"), expectedDataType16); HBufC8 *expectedDataBuf8 = ConvertDes16toHBufC8LC(expectedDataType16); TInt expectedConfidence; GetIntFromConfig(ConfigSection(), _L("expectedConfidence"), expectedConfidence); TInt maxDataBufSize; if (GetIntFromConfig(ConfigSection(), _L("maxDataBufSize"), maxDataBufSize)) { iLs.SetMaxDataBufSize(maxDataBufSize); } TPtrC method; GetStringFromConfig(ConfigSection(), _L("method"), method); TBool checkSpecific = EFalse; TBool matchedSpecificMimeType = EFalse; TPtrC specificMimeType; if (method == KMethodHandle) { checkSpecific = GetStringFromConfig(ConfigSection(), _L("checkSpecificMimeType"), specificMimeType); } TInt usePrivateFile = 0; GetIntFromConfig(ConfigSection(), _L("usePrivateFile"), usePrivateFile); RDeletefile deletefile(iTheFs, iFileName); if(!usePrivateFile) { // Tweak file modification time to defeat the apparch recognizer result cache.... TTime time; User::LeaveIfError(iTheFs.Modified(iFileName, time)); time += TTimeIntervalSeconds(1); User::LeaveIfError(iTheFs.SetModified(iFileName, time)); } else { // Copy file to private dir, this will make it inaccesible to the recognizer code (except via handle). ConvertFileToPrivateL(); CleanupClosePushL(deletefile); } if (method == KMethodName) { INFO_PRINTF2(_L("Test Recognizing %S by File Name"), &iFileName); User::LeaveIfError(iLs.RecognizeData(iFileName, KEmptyBuffer8, recogResult)); } else if((method == KMethodHandle) || (method == KMethodBuffer)) { RFile fileToRead; User::LeaveIfError(fileToRead.Open(iTheFs, iFileName, EFileShareReadersOrWriters | EFileRead | EFileStream)); CleanupClosePushL(fileToRead); if(method == KMethodHandle) { if (checkSpecific) { HBufC8* specificMimeType8 = ConvertDes16toHBufC8LC(specificMimeType); TDataType mime(*specificMimeType8); INFO_PRINTF2(_L("Test matching specific mime-type %S by Handle"), &iFileName); User::LeaveIfError(iLs.RecognizeSpecificData(fileToRead, mime, matchedSpecificMimeType)); CleanupStack::PopAndDestroy(specificMimeType8); } else { INFO_PRINTF2(_L("Test Recognizing %S by Handle"), &iFileName); User::LeaveIfError(iLs.RecognizeData(fileToRead, recogResult)); } } else { INFO_PRINTF2(_L("Test Recognizing %S by Buffer"), &iFileName); TInt size; User::LeaveIfError(fileToRead.Size(size)); TInt maxBufferSize; if(GetIntFromConfig(ConfigSection(), _L("maxBufferSize"), maxBufferSize)) { if(size > maxBufferSize) { size = maxBufferSize; } } HBufC8* memForFile = HBufC8::NewLC(size); TPtr8 fileContent(memForFile->Des()); User::LeaveIfError(fileToRead.Read(fileContent, size)); User::LeaveIfError(iLs.RecognizeData(iFileName, fileContent, recogResult)); CleanupStack::PopAndDestroy(); //memForFile, } CleanupStack::PopAndDestroy(&fileToRead); } else { ERR_PRINTF1(_L("method not set correctly")); User::Leave(KErrArgument); } if (checkSpecific) { if (matchedSpecificMimeType) { INFO_PRINTF2(_L("Specific type '%S' matched\n"), &specificMimeType); SetTestStepResult(EPass); } else { INFO_PRINTF2(_L("Specific type '%S' not matched\n"), &specificMimeType); SetTestStepResult(EFail); } } else { TPtrC result16 = recogResult.iDataType.Des(); if (// Expected failure ((expectedConfidence == CApaDataRecognizerType::ENotRecognized) && (recogResult.iDataType != expectedDataBuf8->Des())) || // Expected success ((recogResult.iConfidence == expectedConfidence) && (recogResult.iDataType == expectedDataBuf8->Des()))) { INFO_PRINTF3(_L("PASSED - type '%S' confidence=%d\n"), &result16, recogResult.iConfidence); SetTestStepResult(EPass); } else { ERR_PRINTF5(_L("FAILED - expected '%S', got type '%S' - expected confidence=%d got confidence %d\n"), &expectedDataType16, &result16, expectedConfidence, recogResult.iConfidence); SetTestStepResult(EFail); } } if(usePrivateFile) { CleanupStack::PopAndDestroy(&deletefile); } CleanupStack::PopAndDestroy(expectedDataBuf8); INFO_PRINTF1(KCompleted); }