예제 #1
0
int CloseFileStream(wofstream &myfile) {
	if (myfile.is_open()) {
		myfile.flush();
		myfile.close();
	}
	return status_ok;
}
예제 #2
0
int WriteFileRaw(wofstream &myfile, wstring resultData) {
	if (myfile.is_open()) {
		myfile << std::time(NULL) << L":" << resultData << endl;
		myfile.flush();
	} else
		return status_query_failed;
	return status_ok;
}
예제 #3
0
int OpenFileStream(wofstream &myfile, wstring fileName, bool recreate) {

	if (recreate)
		myfile.open(fileName, ios::out);
	else
		myfile.open(fileName, ios::out | ios::app);
	if (myfile.is_open()) {
		std::locale loc(std::locale::classic(), new std::codecvt_utf8<wchar_t>);
		myfile.imbue(loc);
		return status_ok;
	} else
		return status_io_error;
}
예제 #4
0
int WriteFileLog(wofstream &myfile, wstring data) {
	if (myfile.is_open()) {
		struct tm lt;

		time_t now_local = time(NULL);
		localtime_s(&lt, &now_local);

		wchar_t szBuf[2148] = L"";
		_snwprintf_s(szBuf, 2148, 2148, L"[%d-%02d-%02d %02d:%02d:%02d]: %s",
				lt.tm_year + 1900, lt.tm_mon + 1, lt.tm_mday, lt.tm_hour,
				lt.tm_min, lt.tm_sec, data.data());
		myfile << szBuf << endl;
#ifdef REC_TEST_CONSOLE
		wcout<< szBuf << endl;
#endif

		myfile.flush();
	} else
		return status_query_failed;
	return status_ok;
}