コード例 #1
0
/******************************************************************************************************
void strip_file(std::ifstream& inStream, std::string fileName)

Description: Opens a input file and strips symbols and outputs to temp file.

Parameters: std::ifstream& inStream, std::string fileName

Pre-Conditions: Input file must be opened.
Post-Conditions: Input file will be stripped of symnbols and output to temp file.
******************************************************************************************************/
void strip_file(std::ifstream& inStream, std::fstream& tempStream)
{
    std::vector<char> lines;//create a vector to hold characters.

    while (inStream)//iterate through each line in file.
    {
	   char ch;
	   int count = 0;
	   ch = inStream.get();//Get character from line.
	   while (ch != EOF)//While not end of line.
	   {
		  if (ch != ',' && ch != '[' && ch != ']')//Do not add these symbols.
		  {
			 lines.push_back(ch);//Push character to vector.
			 count++;//inc count, used to loop through vector.
		  }
		  ch = inStream.get();//get next char in line.
	   }
	   for (int i = 0; i < count; i++)
	   {

		  //std::cout << lines[i];  //Outputs each line in file to console.
		  tempStream << lines[i];//Outputs to temp.txt file

	   }
	   lines.clear();//Clears the vector of all values.
    }
    inStream.clear();//clears the end of file flag (eof).
    inStream.seekg(0L, std::ios::beg);//Move back to the beginning of the input file stream.
    tempStream.clear();//clears the end of file flag (eof).
    tempStream.seekg(0L, std::ios::beg);//Move back to the beginning of the input file stream.

}//end strip_file
コード例 #2
0
ファイル: file.hpp プロジェクト: jnferguson/nfcdump
		static void 
		clear(std::fstream& f)
		{
			f.clear();
			errno = 0;

			return;
		}
コード例 #3
0
ファイル: filesystem.cpp プロジェクト: bentley/lsnes
void filesystem::supercluster::save(std::fstream& s, uint32_t index)
{
	uint64_t offset = SUPERCLUSTER_SIZE * index;
	char buffer[CLUSTER_SIZE];
	for(unsigned i = 0; i < CLUSTERS_PER_SUPER; i++)
		serialization::u32b(buffer + 4 * i, clusters[i]);
	s.clear();
	s.seekp(offset, std::ios_base::beg);
	s.write(buffer, CLUSTER_SIZE);
	if(!s)
		throw std::runtime_error("Can't write cluster table");
}
コード例 #4
0
    static int getImageCount(std::fstream& file_list)
    {
        int sample = 0;
        std::string line;
        while (std::getline(file_list, line))
            ++sample;
        if (file_list.eof())
            file_list.clear();  //otherwise we can't do any further I/O
        else if (file_list.bad()) {
            throw  std::runtime_error("Error occured while reading files_list.txt");
        }

        return sample;
    }
コード例 #5
0
ファイル: filestream.cpp プロジェクト: somaen/grime-tools-mac
	virtual bool seek(int32 offset, int whence = SEEK_SET) {
		_fileStream->clear();
		switch (whence) {
			case SEEK_SET:
				_fileStream->seekg(offset, std::ios_base::beg);
				break;
			case SEEK_CUR:
				_fileStream->seekg(offset, std::ios_base::cur);
				break;
			case SEEK_END:
				_fileStream->seekg(offset, std::ios_base::end);
				break;
		}
	}
コード例 #6
0
ファイル: filesystem.cpp プロジェクト: bentley/lsnes
void filesystem::supercluster::load(std::fstream& s, uint32_t index)
{
	uint64_t offset = SUPERCLUSTER_SIZE * index;
	char buffer[CLUSTER_SIZE];
	s.clear();
	s.seekg(offset, std::ios_base::beg);
	s.read(buffer, CLUSTER_SIZE);
	if(!s)
		throw std::runtime_error("Can't read cluster table");
	free_clusters = 0;
	for(unsigned i = 0; i < CLUSTERS_PER_SUPER; i++) {
		if(!(clusters[i] = serialization::u32b(buffer + 4 * i)))
			free_clusters++;
	}
}
コード例 #7
0
void Agente::leerLinea(std::fstream& archivo, std::string& linea) {
	linea.clear();

	char buffer[T_BUFFER];

	bool seguirLeyendo = true;
	do {
		archivo.getline(buffer, T_BUFFER, '\n');
		linea.append(buffer, archivo.gcount());

		seguirLeyendo = (archivo.gcount() == T_BUFFER);

		if (archivo.bad())
			archivo.clear();

	} while (seguirLeyendo);
}
コード例 #8
0
ファイル: CFileManager.cpp プロジェクト: bjonke/Exodus
void CFileManager::FileLoader(std::fstream& i_stream,std::string i_filepath)
{
	i_stream.clear();

	//i_stream.open(i_filepath.c_str());
	i_stream.open("TestData.txt");

	if(i_stream.is_open())
	{
		//i_stream << "opened this file";
		i_stream >> token;
		if(token == "gobblin")
		{
			//characters.push_back( CHARACTER() );
			//LoadGoblin( file, characters.back() ); 
		}
		i_stream.close();
	}
コード例 #9
0
void resultsfile::checkformodifications(std::fstream& file)
   {
   assert(file.good());
   trace << "DEBUG (resultsfile): checking file for modifications." << std::endl;
   // check for user modifications
   sha curdigest;
   file.seekg(0);
   curdigest.process(file);
   // reset file
   file.clear();
   if (curdigest == filedigest)
      file.seekp(fileptr);
   else
      {
      cerr << "NOTICE: file modifications found - appending." << std::endl;
      // set current write position to end-of-file
      file.seekp(0, std::ios_base::end);
      fileptr = file.tellp();
      }
   }
コード例 #10
0
ファイル: parsing.cpp プロジェクト: o-peregudov/libcrs
std::streampos search_forward ( std::fstream & _bs, const std::string & sample )
{
	size_t match ( 0 );
	cSaveIStreamPosition ip ( &_bs );
	streampos result ( static_cast<streampos>( -1 ) );
	cSaveStreamExceptions se ( &_bs, std::ios_base::goodbit );
	
	for( int ch( EOF ); match < sample.length(); match++ )
	{
		ch = _bs.get();
		if( ch == EOF )
			break;
		else if( ch != sample[match] )
			match = 0;
	}
	if( match == sample.length() )
		result = _bs.tellg() - static_cast<streampos>( match );
	
	_bs.clear();
	
	return result;
}
コード例 #11
0
ファイル: main.cpp プロジェクト: apamburn/CS3370
void refreshFstream(std::fstream& fs)
{
	fs.clear();
	fs.seekg(0,fs.beg);
}