/* * Bench string appending */ float StropBencher::appender(int numRuns, int strType, int func) { float startTime = currTime(); std::string str("Ima String!"); std::string appStr("Append me!"); switch(strType) { case MAUTIL_STRING: for(int i = 0; i < numRuns; ++i){ for(int j = 0; j < ALOT; ++j){ if(func == 0) appStr.append("junk", 4); else if(func == 1) appStr += str; //testing operator+= } } /*case STD_STRING: TODO Will have to wait until STL is implemented for(int i = 0; i < numRuns; ++i){ for(int j = 0; j < ALOT; ++j){ mStdStr->append("junk"); } } return currTime() - startTime;*/ } return currTime() - startTime; }
BinaryData & BinaryData::append(uint8_t const * str, uint32_t sz) { BinaryDataRef appStr(str, sz); return append(appStr); }
/** Function to extract specified file from a given image. @internalComponent @released @param aOffset - starting offset of the file in the image. @param aSize - size of the file in the image. @param aFileName - name of the file. @param aPath - full path of the file inside image. @param aFilePath - path where file has to be extracted. */ void ImageReader::ExtractFile(TUint aOffset,TInt aSize,const char* aFileName,const char* aPath,char* aFilePath,char* aData) { // concatenate path where specified file needs to be extracted with // path where file is located in the image. string fullPath( aFilePath ); string delimiter( "\\" ); string appStr( "\\\\" ); fullPath.append( aPath ); // replace all the occurrence of slash with double slash. FindAndInsertString( fullPath, delimiter, delimiter ); // now terminate the string with double slash. fullPath.append( appStr ); // create specified directory where file needs to be extracted. CreateSpecifiedDir( &fullPath[0], appStr.c_str() ); // concatenate path information with the filename fullPath.append( aFileName ); // create an output stream to extract the specified file. ofstream outfile (fullPath.c_str(), ios::out | ios::binary); // create an input stream by opening the specified image file. ifstream infile(ImageReader::iImgFileName.c_str(),ios::in|ios::binary); //declare a buffer to store the data. char* buffer = new char[aSize]; if(aData != NULL) { memcpy(buffer, aData + aOffset, aSize); } else if(infile.is_open()) { // place the get pointer for the current input stream to offset bytes away from origin. infile.seekg(aOffset,ios::beg); //read number of bytes specified by the variable size //from the stream and place it on to buffer. infile.read(buffer,aSize); //close the input stream after reading. infile.close(); } else { throw ImageReaderException(ImageReader::iImgFileName.c_str(), "Failed to open the image file"); } if(outfile.is_open()) { //writes number of bytes specified by the variable size //from buffer to the current output stream. outfile.write(buffer,aSize); //close the output stream after writing. outfile.close(); } else { throw ImageReaderException(aFileName, "Failed to extract the file"); } //delete the buffer. delete[] buffer; }