Example #1
0
bool CDirectoryHelper::CreateDirectoryD(const wchar_t *dir)
{
	DDString::CZString str(dir,wcslen(dir));

	if(L':' != dir[1] || L'\\' != dir[2])
	{
		if(L'\\' == dir[0])
			str = GetModuleDir(0) + str;
		else
		{
			str = GetModuleDir(0) +L"\\"+ str;
		}
	}

	int index = str.IndexOf(L'\\',3);
	//DDString::CZStringW str;
	DDString::CZString strTmp;
	while(-1 != index)
	{
		strTmp = str.SubString(0,index);
		if(strTmp.GetDataLength() > 2 && !DirectoryExist(strTmp.GetData())) // exclude "\" directory, etc.:"\dir\"
		{
			if(!CreateDirectory(strTmp.GetData(),0))
				return false;
		}
		index = str.IndexOf(L'\\',index + 1);
	}
	
	return true;
}
Example #2
0
bool CDirectoryHelper::IsDirectory(const char* name)
{
	if(NULL == name)
		return false;
	if(!DirectoryExist(name))
		return false;

	struct stat st;
	stat(name,&st);
	if(st.st_mode & _S_IFDIR)
		return true;
	return false;
}
BOOL Dowmloadfile::OnInitDialog()
{
	CDialogEx::OnInitDialog();

	// TODO:  Add extra initialization here

	((CComboBox *)GetDlgItem(IDC_COMBO_UPDATE_TYPE))->AddString(_T("Bootloader"));
	((CComboBox *)GetDlgItem(IDC_COMBO_UPDATE_TYPE))->AddString(_T("Main Firmware"));
	((CComboBox *)GetDlgItem(IDC_COMBO_UPDATE_TYPE))->SetCurSel(1);
	((CEdit *)GetDlgItem(IDC_EDIT_SERVER_DOMAIN))->SetWindowText(_T("www.temcocontrols.poweredbyclear.com"));
		
	wait_download_and_isp_finished = false;
	CString temp_id;CString temp_name;
	temp_id.Format(_T("%d"),m_product_isp_auto_flash.product_class_id);
	temp_name = GetProductName(m_product_isp_auto_flash.product_class_id);
	((CEdit *)GetDlgItem(IDC_EDIT_PRODUCT_ID))->SetWindowTextW(temp_id);
	((CEdit *)GetDlgItem(IDC_EDIT_PRODUCT_ID))->EnableWindow(false);
	//((CIPAddressCtrl *)GetDlgItem(IDC_IPADDRESS_TEMCO_IP))->SetAddress(114,93,27,13);
	((CEdit *)GetDlgItem(IDC_EDIT_PRODUCT_NAME))->SetWindowTextW(temp_name);
	((CEdit *)GetDlgItem(IDC_EDIT_PRODUCT_NAME))->EnableWindow(false);
	//int resualt=TCP_File_Socket.Create(0,SOCK_STREAM);//SOCK_STREAM
	downloadfile_hwnd = this->m_hWnd;
	//TCP_File_Socket.SetParentWindow(downloadfile_hwnd);
	Downloadfile_Thread = NULL;
	CString ApplicationFolder;
	download_thread_flag = true;
	GetModuleFileName(NULL, ApplicationFolder.GetBuffer(MAX_PATH), MAX_PATH);
	PathRemoveFileSpec(ApplicationFolder.GetBuffer(MAX_PATH));
	ApplicationFolder.ReleaseBuffer();
	Folder_Path = ApplicationFolder + _T("\\Database\\Firmware");
	if(!DirectoryExist(Folder_Path))
	{
		CreateDirectory(Folder_Path);
	}

	hostent* host = gethostbyname("www.temcocontrols.poweredbyclear.com");
	if(host == NULL)
	{
		MessageBox(_T("Can't access Temco server.\r\n www.temcocontrols.poweredbyclear.com  \r\nPlease check your internet connection!"),_T("Warning"),MB_OK | MB_ICONINFORMATION);
		PostMessage(WM_CLOSE,NULL,NULL);
		return TRUE;
	}
	char* pszIP  = (char *)inet_ntoa(*(struct in_addr *)(host->h_addr)); 
//	IP_ADDRESS[0] = pszIP[0];
	memcpy_s((char *)IP_ADDRESS_SERVER,20,pszIP,20);

	return TRUE;  // return TRUE unless you set the focus to a control
	// EXCEPTION: OCX Property Pages should return FALSE
}
Example #4
0
BOOL CreateFullPath(char * path)
{

	char drive[_MAX_DRIVE];
	char dir[_MAX_DIR];
	char fname[_MAX_FNAME];
	char ext[_MAX_EXT];

	_splitpath(path, drive, dir, fname, ext);

	if (strlen(dir) == 0) return FALSE;

	char curpath[256];
	strcpy(curpath, drive);
	strcat(curpath, "\\");
	long start = 1;
	long pos = 1;
	long size = strlen(dir);

	while (pos < size)
	{
		if ((dir[pos] == '\\') || (dir[pos] == '/'))
		{
			dir[pos] = 0;
			memcpy(curpath + strlen(curpath), dir + start, pos - start + 1);
			strcat(curpath, "\\");
			_mkdir(curpath);
			start = pos + 1;
		}

		pos++;
	}

	if (DirectoryExist(path)) return TRUE;

	return FALSE;
}