bool Workspace::ImportLibrary(Project * project, QString libPath, QString prefixPath) { // first, find the library path if (libPath.indexOf("/") < 0) { QString libName = libPath; libPath = config.LocateFileUsingSearchPaths(libPath, "$(LIBRARIES)", true); if (libPath == "") { msg.Add("Error importing library '" + libName + "' to project. Please add it manually from toobar button", mtError); return false; } } ImportLibraryFilesRecursively(project, libPath, libPath); // Add the list of all .h files to the automatically generated header file QString autoFileName = qApp->applicationDirPath() + "/templates/mariamole_auto_generated.h";// config.workspace + "/" + project->name + "/source/mariamole_auto_generated.h"; QFile autoFile(autoFileName); autoFile.open(QFile::ReadOnly | QFile::Text); QTextStream stream(&autoFile); QString fileContent = stream.readAll(); autoFile.close(); // Remove the last #endif from the file while (fileContent.at(fileContent.length()-1) != '#') { fileContent.remove(fileContent.length()-1, 1); } fileContent.remove(fileContent.length()-1, 1); //fileContent; += "\n\n"; // add all header files for (int i=0; i < project->files.size(); i++) { if (project->files.at(i).type == ptExternal) { QString name = QFileInfo(project->files.at(i).name).fileName(); QString ext = QFileInfo(project->files.at(i).name).suffix().toUpper(); if ( (ext == "H") || (ext == "HPPC") ) { fileContent += "#include <" + name + ">\n"; } } } fileContent += "\n#endif\n"; autoFileName = config.workspace + "/" + project->name + "/source/mariamole_auto_generated.h"; QFile autoFileOutput(autoFileName); autoFileOutput.open(QFile::WriteOnly); //autoFileOutput.setlin //setEolMode(QsciScintilla::EolUnix); QTextStream streamOutput(&autoFileOutput); streamOutput << fileContent; autoFileOutput.close(); modified = true; return true; }
bool JobInfoCommunicator::streamStdFile( const char *which ) { if(!strcmp(which,ATTR_JOB_INPUT)) { return streamInput(); } else if(!strcmp(which,ATTR_JOB_OUTPUT)) { return streamOutput(); } else if(!strcmp(which,ATTR_JOB_ERROR)) { return streamError(); } else { return false; } }
/** Checks for any field that should have not been exported @param aFile The vcs file to open */ TBool CTestCompareCntFiles::CheckForNoFieldL(const TDesC& aFile, const TDesC& aProperty) { RFile fileOutput; CleanupClosePushL(fileOutput); TInt err = fileOutput.Open(iFsSession, aFile, EFileRead); if (err != KErrNone) { ERR_PRINTF2(_L("Unable to open file: %S"), &aFile); SetTestStepResult(EFail); SetTestStepError(err); } RFileReadStream streamOutput(fileOutput); CleanupClosePushL(streamOutput); TBuf8<0x80> bufOutput; TBool result; TBuf8<KMaxLengthField> noField; noField.Copy(aProperty); do { TRAP(err, streamOutput.ReadL(bufOutput, TChar(KLinefeedChar))); result = IsPropertyPresent(bufOutput, noField); if(result) { break; } } while (err != KErrEof); CleanupStack::PopAndDestroy(2, &fileOutput); if(result) { return EFalse; } else { return ETrue; } }
bool Workspace::AddNewFile(QString fullPath) { Project * project = GetCurrentProject(); if (project == NULL) { return false; } if (QFileInfo(fullPath).exists()) { ErrorMessage("File already exists: \n" + fullPath); return false; } QString path = QFileInfo(fullPath).absoluteDir().absolutePath(); if (path != config.workspace + "/" + project->name + "/source") { ErrorMessage("Invalid file name/path: \n" + fullPath); return false; } QString name = QFileInfo(fullPath).fileName(); QString ext = QFileInfo(fullPath).suffix().toUpper(); // create the file QFile autoFileOutput(fullPath); bool ok = autoFileOutput.open(QFile::WriteOnly); if (ok == false) { ErrorMessage("Error creating the file: \n" + fullPath); return false; } QTextStream streamOutput(&autoFileOutput); streamOutput << "/* File automatically created by MariaMole */ \n"; autoFileOutput.close(); modified = true; ProjectFile pfile; pfile.name = name; pfile.open = false; pfile.type = ptSource; project->files.push_back(pfile); return true; }
/** Compares 2 vcf fie @param aExpectedFile The expected vcf file @param aFile This is the vcf file produced, and will be compared against aExpectedFile @param aProperty This is the property we are interested in */ void CTestCompareCntFiles::CompareFileL(const TDesC& aExpectedFile, const TDesC& aFile, TDes8& aProperty) { RFile fileExpected; RFile fileOutput; CleanupClosePushL(fileExpected); CleanupClosePushL(fileOutput); TInt err = KErrNone; err = fileExpected.Open(iFsSession, aExpectedFile, EFileRead); if (err != KErrNone) { ERR_PRINTF2(_L("Unable to open file: %S"), &aExpectedFile); SetTestStepResult(EFail); SetTestStepError(err); } err = fileOutput.Open(iFsSession, aFile, EFileRead); if (err != KErrNone) { ERR_PRINTF2(_L("Unable to open file: %S"), &aFile); SetTestStepResult(EFail); SetTestStepError(err); } RFileReadStream streamExpected(fileExpected); RFileReadStream streamOutput(fileOutput); CleanupClosePushL(streamExpected); CleanupClosePushL(streamOutput); TBuf8<0x80> bufExpected,bufOutput; TBool isProperty = EFalse; TBool isPropertyExpected = EFalse; TBool foundBothProperty = EFalse; TBool flag = EFalse; TInt err1 = KErrNone; do // This do loop iterates through both files, until the end of file is found { do // This do loop iterates thorugh both files until both properties are found and compares them { foundBothProperty = EFalse; if (!isProperty) { TRAP(err, streamExpected.ReadL(bufExpected, KLinefeedChar)); } if (!isPropertyExpected) { TRAP(err1, streamOutput.ReadL(bufOutput, KLinefeedChar)); } if (err != KErrEof || err1 != KErrEof) { isProperty = IsPropertyPresent(bufExpected, aProperty); // checks if aProperty if(isProperty && err1 == KErrEof) { break; } isPropertyExpected = IsPropertyPresent(bufOutput, aProperty); // checks if aProperty } else { break; } if ((isProperty) && (isPropertyExpected)) { foundBothProperty = ETrue; flag = ETrue; } } while (!foundBothProperty); // exit 2nd do loop when both properties found // Exists 2nd do loop, so both properties are found if (err != KErrEof && err1 != KErrEof) { if(aProperty != KRevision) { CompareLinesL(bufExpected, bufOutput); // compares both properties } else { break; } } // After comparing, gets the next property parameters in vcs file, if we have not reached end of file TRAP(err, streamExpected.ReadL(bufExpected, KLinefeedChar)); TRAP(err1, streamOutput.ReadL(bufOutput, KLinefeedChar)); } while (err != KErrEof || err1 != KErrEof); // exits 2nd do loop when its reached the end of either file TBuf<KMaxLengthField> buf; buf.Copy(aProperty); TPtrC ptr(buf); if(flag) { INFO_PRINTF2(_L("Property: %S Exported properly"), &ptr); } else { INFO_PRINTF2(_L("Property: %S not exported"), &ptr); SetTestStepResult(EFail); } CleanupStack::PopAndDestroy(4, &fileExpected); }