void DataCompressionLayer::softFlush(int flushType) { /* run deflate() on input until output buffer not full, finish compression if all of source has been read in */ //Adapted from http://www.zlib.net/zpipe.c compressor.avail_in = bufferIndex; compressor.next_in = (unsigned char*)inBuf; do { compressor.avail_out = outBufferCurrentSize - posInCompBuffer; assert(outBufferCurrentSize > posInCompBuffer); DEBUGCOUT(2) << "Avail out: " << outBufferCurrentSize - posInCompBuffer<<endl; compressor.next_out = outBuf + posInCompBuffer; int ret = deflate(&compressor, flushType); /* no bad return value */ if (ret == Z_STREAM_ERROR) cerr<<"zlib stream error."<<endl; /* state not clobbered */ posInCompBuffer = outBufferCurrentSize - compressor.avail_out; if (posInCompBuffer == outBufferCurrentSize) //Shoot, our output buffer is full... growOutputBuffer(); } while (compressor.avail_out == 0); assert(compressor.avail_in == 0); bufferIndex = 0; }
BaseDataFile::BaseDataFile(string _filename, int _headerSize) { DEBUGCOUT(1) << "Setting Data File: " << _filename << endl; if (_filename != "") { setData(_filename, _headerSize); } }
/**** * Check if the directory is correct or not. If it is correct, it returns * the XML file and the trace file * * @param directory * (in): the input directory * @param statusMgr * (in): status bar * @param experimentFile * (out): XML file * @param traceFile * (out): trace file * @return true if the directory is valid, false otherwise * */ bool DBOpener::verifyDatabase(string directory, FileData* location) { DEBUGCOUT(2) << "Checking " <<directory<<endl; if (FileUtils::existsAndIsDir(directory)) { DEBUGCOUT(2) << "\tExists and is a directory"<<endl; location->fileXML = FileUtils::combinePaths(directory, XML_FILENAME); DEBUGCOUT(2) << "\tTrying to open "<<location->fileXML<<endl; if (FileUtils::exists(location->fileXML)) { DEBUGCOUT(2) <<"\tXML file is not null"<<endl; try { std::string outputFile = FileUtils::combinePaths(directory, TRACE_FILENAME); DEBUGCOUT(2) <<"\tTrying to open "<<outputFile<<endl; MergeDataAttribute att = MergeDataFiles::merge(directory, "*.hpctrace", outputFile); DEBUGCOUT(2) <<"\tMerge resulted in "<<att<<endl; if (att != FAIL_NO_DATA) { location->fileTrace = outputFile; if (FileUtils::getFileSize(location->fileTrace) > MIN_TRACE_SIZE) { return true; } else { cerr << "Warning! Trace file " << location->fileTrace << "is too small: " << FileUtils::getFileSize(location->fileTrace) << " bytes." << endl; return false; } } else { cerr << "Error: trace file(s) does not exist or fail to open " << outputFile << endl; } } catch (int err) { cerr << "Error code: " << err << endl; } } } return false; }
ProgressBar::ProgressBar(string name, ulong tasksToComplete) { tasks = tasksToComplete; tasksComplete = 0; colsFilled = 0; label = name; struct winsize w; int ret = ioctl(STDOUT_FILENO, TIOCGWINSZ, &w); if (ret == -1 || w.ws_col == 0) w.ws_col = DEFAULT_TERMINAL_WIDTH; usableWidth = w.ws_col - 10 - name.length(); DEBUGCOUT(2) << "Usable width: " << usableWidth << endl; update(); }