All pastes #459204 Raw Edit

Miscellany

public text v1 · immutable
#459204 ·published 2007-04-26 09:54 UTC
rendered paste body
bool InitializeLogFile(wchar_t *path, wchar_t **log_file)
{
	FILE *file;
	size_t length = 34+wcslen(path);
	*log_file = (wchar_t *) calloc(length, sizeof(wchar_t));
	wcscpy_s(*log_file, length, path);
	wcscat_s(*log_file, length, L"logs\\");
	wchar_t buf[26];
	time_t t = time(NULL);
	_wctime_s(buf, 26, &t);
	buf[24] = 0;
	buf[13] = '-';
	buf[16] = '-';
	wcscat_s(*log_file, length, buf);
	wcscat_s(*log_file, length, L".txt");
	wprintf(L"logfile %s\n",log_file);
	errno_t p = _wfopen_s(&file, *log_file, L"w, ccs=UTF-8");
	if ( p != 0 )
	{
		printf("There was some error and p is not 0 p =%d\n",p);
		return false;
	}
	fclose(file);
	return true;
}