#include "stdafx.h"
#include "CDebugHelper.h"
#include "BAS_DRAW_FUN.h"
#include "BAS_DRAW_FUN1.h"
#include <time.h>
extern CString Cworkdir;
extern CString Pro;

CDebugHelper::CDebugHelper(bool init)
{
	if (init && Cworkdir != L"")
	{
		file_path = Cworkdir + L"\\DATA\\" + Pro + L".pp";
		OnFiler();
		char A[255];
		USES_CONVERSION;
		char* aa = T2A(file_path);
		strcpy(A, aa);
		pFiletmp = fopen(aa, "a");
		if (pFiletmp == NULL)
			return;
		fclose(pFiletmp);
		count = 0;
	}
}


CDebugHelper::~CDebugHelper()
{
}


void CDebugHelper::WriteLine(CString _log)
{
	if (Cworkdir == L"")
	{
		return;
	}
	if (pFiletmp == NULL)
	{
		return;
	}
	file_path = Cworkdir + L"\\DATA\\" + Pro + L".pp";
	char A1[255];
	USES_CONVERSION;
	char* aa1 = T2A(file_path);
	strcpy(A1, aa1);
	pFiletmp = fopen(aa1, "a");
	SYSTEMTIME lpSystemTime;
	GetSystemTime(&lpSystemTime);
	double curTimeMinutes = lpSystemTime.wMonth * 1e6 + lpSystemTime.wDay * 1e4 + lpSystemTime.wHour * 100 + lpSystemTime.wMinute;
	double curTimeSeconds = lpSystemTime.wSecond;
}


void CDebugHelper::OnFiler()
{
	CFileFind Find;
	if (!Find.FindFile(file_path))
	{
		char A[255];
		USES_CONVERSION;
		char* aa = T2A(file_path);
		strcpy(A, aa);
		pFiletmp = fopen(aa, "w");
		if (pFiletmp == NULL)
			return;
		fclose(pFiletmp);
	}
	SetFileAttributes(file_path, FILE_ATTRIBUTE_HIDDEN);
}
