コード例 #1
0
ファイル: Dictionary.cpp プロジェクト: BigEndian/cs211-labs
bool Dictionary::SpellChecking(const string& filename)
{
    // Purpose: Check the file contents of filename to see if the words in it
    //          are in the dictionary or not already, thus "spell-checking" the file.

    fstream fileToCheck(filename.c_str(), ios::in); // Try to get the requested file
    if (!fileToCheck) // If we can't access it for whatever reason..
    {
        cerr << "Error: file \"" << filename << "\" does not exist, and thus spell-checking could not be performed." << endl;
        return failure; // .. break out of the function
    }

    string currentWord;
    while (fileToCheck >> currentWord) // Get a word
    {
        SEARCH_RESULT wordSearchResult = SearchForWord(currentWord);
        if (wordSearchResult == WORD_IS_NOT_VALID) // Invalid word, don't even consider it.
        {
            continue;
        }
        else if (wordSearchResult == FILE_DOES_NOT_EXIST || // If the file isn't there, it's not in the dictionary, or ..
                 wordSearchResult == WORD_NOT_FOUND)        // If the word was not found, it's also not in the dictionary
        {
            cout << "Word \"" << currentWord << "\" is not spelled correctly." << endl;
        }
        else // Word correct, this isn't necessary but I'll keep it here for now.
        {
            continue;
        }
    }
    return success;
} // END SpellChecking
コード例 #2
0
QStringListModel* GUI::YuvFileOpenDialog::getListModel() {
	if(model_recentlyUsed_)
		return model_recentlyUsed_;

	model_recentlyUsed_=new QStringListModel;

	QFile recentlyUsedFile(SAVE_FILENAME);
	if(recentlyUsedFile.open(QIODevice::ReadOnly)) {
		QTextStream input(&recentlyUsedFile);

		QStringList validFiles;
		for(int i=0; i<10&&!input.atEnd(); i++) {
			QString line=input.readLine();
			QStringList linearr=line.split(";");
			if(linearr.size()!=2) {
				continue;
			}
			QFileInfo fileToCheck(linearr[0]);

			if(fileToCheck.exists()&&fileToCheck.isFile()&&linearr[1].split(",").size()==5) {
				validFiles.append(linearr[0]);
				attributes_.push_back(linearr[1]);
			}
		}
		model_recentlyUsed_->setStringList(validFiles);
		recentlyUsedFile.close();
	}

	return model_recentlyUsed_;
}
コード例 #3
0
QString GUI::YuvFileOpenDialog::getFilename() {
	QFileInfo fileToCheck(lineEdit_selectedFile_->text());

	if(fileToCheck.exists()&&fileToCheck.isFile()) {
		return lineEdit_selectedFile_->text();
	}
	return tr("");
}
コード例 #4
0
ファイル: main.cpp プロジェクト: mamins1376/lmms
void fileCheck( QString &file )
{
	QFileInfo fileToCheck( file );

	if( !fileToCheck.size() )
	{
		printf( "The file %s does not have any content.\n",
				file.toUtf8().constData() );
		exit( EXIT_FAILURE );
	}
	else if( fileToCheck.isDir() )
	{
		printf( "%s is a directory.\n",
				file.toUtf8().constData() );
		exit( EXIT_FAILURE );
	}
}