コード例 #1
0
ファイル: merge.cpp プロジェクト: torkve/eblob
	em_blob(const char *path) : completed(0), path_(path) {
		try {
			data.open(path, std::ios_base::in | std::ios_base::binary);
			std::string index_path(path);
			index_path += ".index";
			index.open(index_path.c_str(), std::ios_base::in | std::ios_base::binary);
		} catch (...) {
			data.close();
			index.close();

			throw;
		}
	}
コード例 #2
0
	void ConfigLoader::parseScript(std::ifstream &stream)
	{
		//Get first token
		_nextToken(stream);
		if (tok == TOKEN_EOF)
		{
			stream.close();
			return;
		}
 
		//Parse the script
		_parseNodes(stream, 0);
 
		stream.close();
	}
コード例 #3
0
ファイル: file_reader.hpp プロジェクト: GHamrouni/utxx
 /// destructor
 ~basic_file_reader() {
     if (!m_open) return;
     try {
         m_file.close();
     } catch (...) {
     }
 }
コード例 #4
0
 void open( const std::string& anchorFile ) {
   _in.close();
   _in.clear();
   _in.open( anchorFile.c_str() );
   _buffer.clear();
   _readDocumentHeader();
 }
コード例 #5
0
ファイル: counter.cpp プロジェクト: EthanJamesLew/hw3
Counter::Counter(std::ifstream &file)
{
	numWords = 0;
	numChars = 0;
	numLines = 0;
	numDigits = 0;
	numLower = 0;
	numUpper = 0;
	lineCond = 0;
	lineCond2 = 0;
	std::string word;
	std::string line;

	//Read by word
	while (file.peek() != EOF)
	{
		
		getline(file, line);
		numWords += wordInStr(line);
		numChars += line.length();
		numDigits += numInStr(line);
		numLower += lowerInStr(line);
		numUpper += upperInStr(line);
		if ((numInStr(line) >= 1) && (lowerInStr(line)>=1))
		{
			lineCond += 1;
			if ((numInStr(line) >= 2) && (lowerInStr(line) >= 3))
			{
				lineCond2 += 1;
			}
		}

	}
	file.close();
}
コード例 #6
0
/*
monitor memory consumption information
*/
VOID WINAPI memoryMonitor()
{
	HANDLE hProc = NULL;
	PROCESS_MEMORY_COUNTERS pmc;
	SIZE_T tmp = 0;
	while (true)
	{
		hProc = GetCurrentProcess();		
		GetProcessMemoryInfo(hProc, &pmc, sizeof(pmc));
		CloseHandle(hProc);
		tmp = pmc.PagefileUsage + pmc.WorkingSetSize + pmc.QuotaNonPagedPoolUsage + pmc.QuotaPeakPagedPoolUsage;
		memoryCost = tmp > memoryCost ? tmp : memoryCost;
		if (memoryCost > (SIZE_T)MEMORY_OUT * (SIZE_T)1024 * (SIZE_T)1024) //eat too much memory
		{
			ResetEvent(eExit);
			WaitForSingleObject(eBlock, INFINITE);
			//so far, all workers have exited
			fTask.close();
			DumpTasks();
			outputStatistics();
			exit(0);
		}
		Sleep(1000 * 1);//sleep 1 sec
	}
}
コード例 #7
0
ファイル: b_log.cpp プロジェクト: Fenolftalein/GeoScan
void BFieldLog::readPack (std::ifstream &in)//, uint8_t &head1, uint8_t &head2)
{
	if (in.eof())
	{
		in.close();
		return;
	}

	in.read(reinterpret_cast<char*>(&packnum_), sizeof(packnum_));
	in.read(reinterpret_cast<char*>(&time_), sizeof(time_));
	in.read(reinterpret_cast<char*>(&freq_), sizeof(freq_));
	in.read(reinterpret_cast<char*>(&sign1_), sizeof(sign1_));
	in.read(reinterpret_cast<char*>(&sign2_), sizeof(sign2_));
	in.read(reinterpret_cast<char*>(&temp1_), sizeof(temp1_));
	in.read(reinterpret_cast<char*>(&temp2_), sizeof(temp2_));
	in.read(reinterpret_cast<char*>(&flags_), sizeof(flags_));
	in.read(reinterpret_cast<char*>(&crc_), sizeof(crc_));

//	pack_num.push_back(packnum_);
//	time_marks.push_back(time_);
//	frequency.push_back(freq_);
//	signal_1.push_back(sign1_);
//	signal_2.push_back(sign2_);
//	temp_sensor.push_back(temp1_);
//	temp_lamp.push_back(temp2_);
//	flag.push_back(flags_);
}
コード例 #8
0
  bool closeEdgeFile(int iter_counter) {
 	 if (fin.is_open()) {
 		 fin.close();
 		 //logstream(LOG_INFO) << "close edge block-" << block_id << std::endl;
 	 }
 	 return true;
  }
コード例 #9
0
bool TetraTools::GMSHMeshLoader::ParseFile(std::ifstream& file_)
{
	std::string cmd;
	unsigned int gmshFormat = 0;
	std::getline(file_, cmd); //Version
	std::istringstream versionReader(cmd);
	std::string version;
	versionReader >> version;
	std::string line;
	if (version == "$MeshFormat") // Reading gmsh 2.0 file
	{
		gmshFormat = 2;
		std::getline(file_, line); // we don't care about this line (2 0 8)
		std::getline(file_, cmd); // end Version
		std::istringstream endMeshReader(cmd);
		std::string endMesh;
		endMeshReader >> endMesh;

		if (endMesh != std::string("$EndMeshFormat") ) // it should end with $EndMeshFormat
		{
			std::cerr << "Closing File as it doesn't end with $EndMeshFormat" << std::endl;
			file_.close();
			return false;
		}
		else
		{
			std::getline(file_, cmd); // First Command
		}
	}
コード例 #10
0
void ErrorCodePrintOut(int num)
{
	switch (num)
	{
	case (INFILE_ERROR + OUTFILE_ERROR) :
	{
		std::cout << "There was an error opening both the input and output files." << std::endl;
		break;
	}
	case INFILE_ERROR:
	{
		 std::cout << "Could not open the provided input file" << std::endl;
		 out_file.close();
		 break;
	}
	case OUTFILE_ERROR:
	{
		std::cout << "Could not open the provided output file or do not have write permission" << std::endl;
		in_file.close();
		break;
	}
	default:
		break;
	}
}
コード例 #11
0
ファイル: main.cpp プロジェクト: hcorrada/methylFlow_analyses
void readMatchMatrix() {
    //reading the match file for pruning the matched edges
    int id, matchId;
    float abdnc, weight, var;
    
    // mFile.open("/cbcb/project-scratch/fdorri/Code/methylFlow/testing/match.txt");
    mFile >> truePatternNum  >> estimatedPatternNum ;
    for (int i = 0; i < truePatternNum ; i++){
        mFile >> id >> abdnc;
        idTrue.push_back(id);
        abdnc_map[id] = abdnc;
    }
    for (int i = 0; i < estimatedPatternNum ; i++){
        mFile >> id >> abdnc;
        idEstimated.push_back(id);
        abdnc_map[id] = abdnc;
    }
    
    for (int i=0; i< truePatternNum ; i++ ){
        mFile >> var >> id >> matchId >> weight ;
        matchTrue_map[id] = matchId;
        weight_map[id] = weight;
        matchEstimated_map[matchId] = id;
    }
    
    mFile.close();
}
コード例 #12
0
ファイル: MyPinTool.cpp プロジェクト: imholulu/DTA
VOID InvokeFunTaint()
{
	string infileName = "c:\\pinInput.txt";
	ADDRINT argu0=0;
	ADDRINT argu1=0;


	in.open(infileName.c_str());


	in >> hex;

	in >> argu0;
	in >> argu1;

	in.close();

	out <<"argu0 " <<argu0 <<endl;

	out <<"argu1 " <<argu1 <<endl;

	if(argu1!=0)
	{
		int n = 2*wcslen((wchar_t *)argu1);
		out <<endl<<"senmatic: argu2"<<endl;
		out << "variable address: "<<argu1<<endl;
		out <<"variable type: BSTR"  << endl;
		out <<"variable length-byte: " << n <<endl;
		ADDRINT taint = (ADDRINT)argu1;
		AddTaint(taint,n,type_WORD);
		InsertTaintInstrumentation();//find taint source , then enable DTA and instruction-level taint analysis
	}
}
コード例 #13
0
void RegionFileLoader::LoadDataFromFile(std::ifstream &file)
{
    if (file.fail())
    {
        std::cerr << "Error <RegionFileLoader::LoadDataFromFile> File is unreadable" <<  std::endl;
        return;
    }

    Double_t sa;
    std::string aline;
    std::stringstream ss;
    while(1)
    {
        std::getline(file,aline);
        if ( FileIsNotOkay(file) )
            break;
        else if ( LineShouldBeSkipped(aline) )
            continue;
        else if ( BeginningOfRegions(aline) )
        {
//            std::cout << aline << std::endl;
            Regions regions = ReadRegions(file);
            if (regions.size()>0)
                fTheRegions.push_back(regions);
        }
    }

    file.close();

}
コード例 #14
0
ファイル: FireMesh.cpp プロジェクト: chraibi/jpscore
void FDSMesh::ReadMatrix(std::string line, std::ifstream &pFile)
{
    int m = 0;
    int n;
    std::vector<std::string> strVec;
    while (std::getline(pFile, line)) {
        n = 0;
        strVec = split2(line, ',', strVec);
        for (auto &elem : strVec)
        {
            //std::cout << elem << " col " << n  << " line " << m << std::endl;
            if (elem=="nan" || elem=="NAN" || elem=="NaN" || elem=="-inf" || elem=="inf")
            {
                _matrix[m][n].SetValue(1.0);
                //Log->Write("ERROR: Mesh values consist of nan!");
                //exit(EXIT_FAILURE);
            }
            else
                _matrix[m][n].SetValue(std::stod(elem));
            ++n;
        }
        strVec.clear();
        ++m;
    }

    pFile.close();
    _statMesh=true;
}
コード例 #15
0
ファイル: JsonReader.cpp プロジェクト: dtbinh/darkmatter
JsonNode JsonReader::Parse(std::ifstream &file) {
   std::string keyname;

   file.seekg(0, std::ios::end);
   m_size = static_cast<size_t>(file.tellg());

   m_data = new char[m_size];

   m_start = m_data;
   m_end = m_start + m_size;

   file.seekg(0, std::ios::beg);
   file.read(m_data, m_size);
   file.close();

   this->SkipWhiteSpaces();

   JsonNode root;

   /* The root element of a JSON document has to be an object or an array. */
   if (*m_data == '[') {
      root = this->ParseArray();
   } else if (*m_data == '{') {
      root = this->ParseObject();
   } else {
      PrintError("Syntax Error : '{' , '[' were expected. ");
   }

   /* clean up */
   delete[] m_start;

   return root;
}
コード例 #16
0
ファイル: distribution.cpp プロジェクト: Beifang/polyscape
int HomoAndMicrosateDis(int argc, char *argv[]) {
    if (argc == 1) DisUsage();
    for (int i=0; i<argc; i++) {
        std::cout <<argv[i]<<' ';
    }
    Initial_Time();
    std::cout <<"Start at:  "<<Curr_Time()<< std::endl;
    int noptions = dGetOptions(argc, argv);
    // process user defined region
    if (!one_region.empty()) {  
        if (!polyscan.ParseOneRegion(one_region)) {
            std::cerr<<"fatal error: Please give correct defined region format (-r) \n";
            exit(1);
        }
        polyscan.ifUserDefinedRegion = true;
    } else {
        polyscan.ifUserDefinedRegion = false;
    }
    // reading bed file if is exist
    finB.open(bedFile.c_str());
    if (finB) {
        std::cout << "loading bed regions ..." << std::endl;
        polyscan.LoadBeds(finB);
        polyscan.BedFilterorNot();
    }
    // check bam list file
    finM.open(bamListFile.c_str());
    if (!finM) {
        std::cerr<<"fatal error: failed to open bam list file\n";
        exit(1);
    }
    std::cout << "loading bam list ..." << std::endl;
    polyscan.LoadBams(finM);
    // check h**o/microsate file
    finH.open(homoFile.c_str());
    if (!finH) {
        std::cerr<<"fatal error: failed to open homopolymer and microsatellites file\n";
        exit(1);
    }
    std::cout << "loading homopolymer and microsatellite sites ..." << std::endl;
    polyscan.LoadHomosAndMicrosates(finH);
    finH.close();
    //polyscan.TestHomos();
    polyscan.SplitWindows();
    //polyscan.TestWindows();
    std::cout << "\nTotal loading windows:  " << polyscan.totalWindowsNum << " \n\n";
    std::cout << "\nTotal loading homopolymer and microsatellites:  " << polyscan.totalHomosites << " \n\n";
    // pour out distribution
    foutD.open( disFile.c_str() );
    if (!foutD) {
        std::cerr <<"failed to open file: "<<disFile<< std::endl;
        exit(1);
    }
    polyscan.GetHomoDistribution(foutD);
    foutD.close();
    std::cout << "\nTotal time consumed:  " << Cal_AllTime() << " secs\n\n";

    return 0;
}
コード例 #17
0
//-------------------------INTERFACE------------------------
BOOL IFileManager::ImportFile_3DS(
	NFilePath pFilePath,
	std::vector<NVECTOR3>& outVertexBuffer, 
	std::vector<NVECTOR2>& outTexCoordList, 
	std::vector<UINT>& outIndexBuffer, 
	std::vector<N_MeshSubsetInfo>& outSubsetList, 
	std::vector<N_Material>& outMaterialList,
	std::unordered_map<std::string, NFilePath>& out_TexName2FilePathPairList)
{
	static_meshObjList.clear();
	static_materialList.clear();
	static_TexName2FilePathPairList.clear();

	fileIn.open(pFilePath, std::ios::binary);

	if (!fileIn.good())
	{
		DEBUG_MSG1("Noise File Manager : Import .3ds file failed!!");
		return FALSE;
	}

	fileIn.seekg(0, std::ios::end);
	static_currentChunkFileEndPos = 0;
	static_fileSize = fileIn.tellg();
	fileIn.seekg(0);

	//maybe linearly deal with chunks is also OK....
	//stack will be used when necessary because recursive solution
	//can sometimes be rewritten in non-recursive form using stack.
	while (!fileIn.eof() && fileIn.good())
	{
		ReadChunk();
	}
	fileIn.close();

	//Finish Parsing,check if Vertices/Indices had been loaded
	auto& vertexList = static_meshObjList.back().verticesList;
	if (vertexList.size() == 0 || vertexList.size() == 0)
	{
		DEBUG_MSG1("Noise File Manager :Data Damaged!!!No Vertices or Indices loaded!");
		return FALSE;
	}


	//std::move transform lval into rval to avoid copying happens
	N_Load3ds_MeshObject finalMeshObj;
	IntegratePartialMeshIntoOnePiece(finalMeshObj);
	outIndexBuffer = std::move(finalMeshObj.indicesList);
	outVertexBuffer = std::move(finalMeshObj.verticesList);
	outTexCoordList = std::move(finalMeshObj.texcoordList);
	outSubsetList = std::move(finalMeshObj.subsetList);
	outMaterialList = std::move(static_materialList);
	out_TexName2FilePathPairList = std::move(static_TexName2FilePathPairList);

	//used to generate unique name
	++static_MeshIndex;

	return TRUE;
}
コード例 #18
0
			static uint64_t getFileLength(std::string const & filename)
			{
				std::ifstream istr(filename.c_str());
				istr.seekg(0,std::ios::end);
				uint64_t const l = istr.tellg();
				istr.close();
				return l;
			}
コード例 #19
0
 /**
 Read entire file into a string at once.
 */
 void read_file(std::ifstream &ifs, std::string &data_read) {
     ifs.seekg(0, std::ios::end);
     size_t size = ifs.tellg();
     data_read.resize(size);
     ifs.seekg(0);
     ifs.read(&data_read[0], size);
     ifs.close();
 }
コード例 #20
0
ファイル: laserxa.hpp プロジェクト: tlatzko/gloc
    void
    close ()
    {
      if (file_in_.is_open ())
	{
	  file_in_.close ();
	}
    }
コード例 #21
0
ファイル: tokenst.cpp プロジェクト: baoilleach/obstereo-2-2-x
    /** Opens the filestream with the first file called @p filename
     found by looking 
     successively in the following directories:
     - the current directory
     - in a subdirectory (of the directory below) with the version of 
     OpenBabel as its name
     - the parent directory specified by the environment variable 
     named @p envvar 
     or "BABEL_DATADIR" if @p envvar is not specified, or the compiled-in
     macro BABEL_DATADIR if the environment variable is not set

     \param ifs        Stream to load
     \param filename   Name of the data file to load
     \param envvar     Name of the environment variable 

     \return the name of the file that was opened. This includes the path
     unless it is in current directory

  **/
  std::string OpenDatafile(std::ifstream& ifs, const std::string& filename, 
                           const std::string& envvar)
  {
    ios_base::openmode imode = ios_base::in;
    #ifdef ALL_READS_BINARY //Makes unix files compatible with VC++6
      imode = ios_base::in|ios_base::binary;
    #endif

    // check the current directory
    ifs.close();
    ifs.clear();
    ifs.open(filename.c_str(),imode);
    if(ifs)
      return filename;

    string file;
    const char* datadir = getenv(envvar.c_str());
    if(!datadir)
      datadir = BABEL_DATADIR;

    // check the subdirectory for this version number
    file = datadir;
    file += FILE_SEP_CHAR;
    file += BABEL_VERSION;
    file += FILE_SEP_CHAR + filename;

    ifs.clear();
    ifs.open(file.c_str(),imode);
    if(ifs)
      return file;

    // couldn't find it with the version built in, so try the parent
    file = datadir;
    file += FILE_SEP_CHAR;
    file += filename;

    ifs.clear();
    ifs.open(file.c_str(),imode);

    if (ifs)
      return file;

    ifs.clear();
    ifs.close();
    return(""); // error
  }
コード例 #22
0
 void clearFileStream()
 {
     if (filestream != 0) {
         filestream->close();
         delete filestream;
         filestream = 0;
     }
 }
コード例 #23
0
ファイル: Source1.cpp プロジェクト: kitz99/Problems
int main(){
	long long a, b;
	fin >> a >> b;
	fout << cmmdc(a, b);
	fin.close();
	fout.close();
	return 0;
}
コード例 #24
0
 // This closes the file which was being parsed, if there is one open.
 inline void RestrictedXmlParser::CloseFile()
 {
   if( xmlFileStream.is_open() )
   {
     xmlFileStream.close();
   }
   xmlFileStream.clear();
   xmlStream = &xmlStringStream;
 }
コード例 #25
0
ファイル: p6.cpp プロジェクト: dverona/TAMU312
void initializeInstructionMemory(std::ifstream &fp) {
	std::string line;
	std::string text;
	if (fp.is_open()) {
		while ( getline(fp,line) ) {
			text << line << '\n';
		}
	fp.close();
	}
}
コード例 #26
0
ファイル: warehouse.hpp プロジェクト: Lustres/stock
 Warehourse(std::ifstream& fin, std::string name = "untitled"):_name(name) /*throw*/ {
     while (!fin.eof()) {
         replenish(Commodity(fin)); /*throw*/
     }
     fin.close();
     
     //Note: There a no need to rethrow the exception
     //case if a exception is throwed. the construction is unfinished. so the destructor won't get called
     //thus the old information won't  get covered
 }
コード例 #27
0
ファイル: fuzzface.cpp プロジェクト: jacob-baines/fuzzface
bool FuzzFace::validateGlobalHeader(std::ifstream& p_fileStream, 
                                    boost::filesystem::recursive_directory_iterator& p_iter,
                                    char* p_readBuffer)
{
    if (!p_fileStream.good())
    {
        std::cerr << "File skipped: " << p_iter->path().string()
                  << " failed to open." << std::endl;
        return false;                
    }
            
    //read the global pcap header
    p_fileStream.read(p_readBuffer, 24);
                
    if (p_fileStream.eof())
    {
        std::cerr << "File skipped: " << p_iter->path().string()
                  << " not enough data." << std::endl;
        p_fileStream.close();
        return false;
    }
    
    //check for PCAP magic bytes (little endian)        
    if (memcmp(p_readBuffer, "\xd4\xc3\xb2\xa1", 4) != 0)
    {
        std::cerr << "File skipped: " << p_iter->path().string()
                  << " couldn't find magic bytes." << std::endl;
        p_fileStream.close();
        return false;
    }
    
    //verify link type in PCAP header
    if (memcmp(p_readBuffer + 20, "\x01\x00\x00\x00", 4) != 0)
    {
        std::cerr << "File skipped: " << p_iter->path().string() 
                  << " link type is not ethernet." << std::endl;
        p_fileStream.close();
        return false;
    }
    
    return true;
}
コード例 #28
0
ファイル: mem_dump.cpp プロジェクト: cbig/zonation-core
bool
load_vmat_raw(std::ifstream& f, size_t xdim, size_t ydim, int map_cnt)
{
  char* in_magic = new char[strlen(magic)];
  f.read((char*)in_magic, strlen(magic));
  // TODO: do some check here
  delete[] in_magic;
  size_t in_xdim, in_ydim;
  int in_map_cnt;
  f.read((char*)&in_xdim, sizeof(in_xdim));
  f.read((char*)&in_ydim, sizeof(in_ydim));  
  f.read((char*)&in_map_cnt, sizeof(in_map_cnt));

  if (in_xdim != xdim || in_ydim != ydim) {
    Form1->Memo1->Lines->Add(" FATAL ERROR: dimensions do not match. In current setup, columns: "+
			     IntToStr(xdim)+", rows: "+IntToStr(ydim)+", whereas in vmat file, columns: "+
			     IntToStr(in_xdim)+", rows: "+IntToStr(in_ydim)+".");
    return false;
  } else {
    Form1->Memo1->Lines->Add("Dimensions match, columns: "+IntToStr(xdim)+
			     ", rows: "+IntToStr(ydim));    
    Form1->Memo1->Lines->Add("Features in vmat file: "+IntToStr(in_map_cnt)+ 
			     ", features in current setup: "+IntToStr(map_cnt));
  }

  Form1->Memo1->Lines->Add("Size BFOC_size_t: "+IntToStr(sizeof(BFOC_size_t))+
			   ", size key_t: "+IntToStr(sizeof(*Biodiv_Features_Occur_Container::priv_key))+
			   ", size val_t: "+IntToStr(sizeof(*Biodiv_Features_Occur_Container::priv_val)));

  BFOC_size_t len = 0;
  for (size_t y=0; y<ydim; y++) {
    for (size_t x=0; x<xdim; x++) {
      f.read((char*)&len, sizeof(len));
      if (0 == len)
	continue;

      BFOC_size_t idx;
      float val;
      // resize the Biodiv_Features_Occur_Container& and load values
      Biodiv_Features_Occur_Container& occ = vmat[y][x];
      occ.reserve(len, len);
      occ.priv_size = len;
      for (BFOC_size_t table_idx=0; table_idx<len; table_idx++) {
	f.read((char*)&(occ.priv_key[table_idx]), sizeof(*occ.priv_key));
	f.read((char*)&(occ.priv_val[table_idx]), sizeof(*occ.priv_val));
      }
    }
    if (0 == (y+1)%REPORT_PERIOD)
      Form1->Memo1->Lines->Add(" Loaded "+IntToStr(y+1)+" rows...");
  }

  f.close();
  return true;
}
コード例 #29
0
 inline void
 AsciiXmlParser::closeFile()
 // this closes fileToParse, if it was open.
 {
   if( fileParsingStream.is_open() )
   {
     fileParsingStream.close();
   }
   fileParsingStream.clear();
   textStream = &stringParsingStream;
 }
コード例 #30
0
int main(int argc, char* argv[]){
    if (argc != 3) {
	    std::cout << argv[0] << " called with incorrect arguments. "<< std::endl;
	    std::cout << "Usage:" << std::endl;
	    std::cout << argv[0] << " infile outfile" << std::endl;
    	exit(-1);
    }

    infile.open(argv[1], ios::binary); // Open input file
    outfile.open(argv[2], ios::binary); // Open output file

	BitInputStream* input = new BitInputStream(infile);

    if(infile.is_open()) {

        // Read the number of unique bytes
        unsigned int tlength = input -> readInt(); 
        // Read the length of the original text
        int textbytes = input -> readInt();

        // Read the frequencies of each byte from the header
	    unsigned int i = 0; // Start past the two nums, at the actual header
        while( i < tlength) {
            int d = input -> readInt();
            int s = input -> readByte();
            
            freq[s] = d;
            i++;
       } 
        
       // Build the tree from the frequencies
        HCTree* myTree = new HCTree();
        myTree->build(freq);

        //Decode individual bytes
        int y = 0;
        while (infile.good() && y < textbytes) {
            int decoded = myTree -> decode(*input);
            outfile.put((unsigned char)decoded);
            y++;
        }
        outfile.flush();
    }
    else {
        std::cout << argv[0] << " called with incorrect arguments. "<< std::endl;
	    std::cout << "Usage:" << std::endl;
	    std::cout << argv[0] << " infile outfile" << std::endl;
    	exit(-1);
    }

    infile.close();
    outfile.close();
}