Ejemplo n.º 1
0
void PathManager::DeleteDirectory( CString strDir )
{
	if(strDir.IsEmpty())   
	{
		RemoveDirectory(strDir);  
		return;  
	}

	//   首先删除文件及子文件夹  
	CFileFind   ff;  
	BOOL   bFound   =   ff.FindFile(strDir+_T("\\*"),   0);  
	while(bFound)  
	{  
		bFound   =   ff.FindNextFile();  
		if(ff.GetFileName()==_T(".")||ff.GetFileName()==_T(".."))  
			continue;  
		//   去掉文件(夹)只读等属性  
		SetFileAttributes(ff.GetFilePath(),   FILE_ATTRIBUTE_NORMAL);  
		if(ff.IsDirectory())  
		{  
			//   递归删除子文件夹  
			DeleteDirectory(ff.GetFilePath());  
			RemoveDirectory(ff.GetFilePath());  
		}  
		else  
		{  
			//   删除文件  
			DeleteFile(ff.GetFilePath());  
		}  
	}  
	ff.Close();  

	//   然后删除该文件夹  
	RemoveDirectory(strDir);
}
Ejemplo n.º 2
0
// Deletes all the unused files that are no longer in the DEP
void Project::DeleteUnused(DEP* thisDEP) {
	CMainFrame* pFrame = (CMainFrame*)AfxGetApp()->m_pMainWnd;
	CFileFind finder;
	INXString fileName, depPath, csProjectDir;
	INXPOSITION pos;
	ConData* blob;
	bool fileExist = FALSE;
	CFileOperation fo;
	
	pProjMData->getProjectDir(csProjectDir);
	depPath = csProjectDir + DEPDIR + pFrame->m_wndProjectBar.m_cProjTree.GetDEPPath(thisDEP->hItem) + thisDEP->depFilename + "\\";
	int bWorking = finder.FindFile(depPath + "*.prg");	
	while (bWorking)
	{
		fileExist = FALSE;
		bWorking = finder.FindNextFile();
		fileName = finder.GetFileName();
		fileName.MakeReverse();
		fileName.Delete(0,4);
		fileName.MakeReverse();
		// check if the file exists in the DEP
		pos = thisDEP->condata->GetHeadPosition();
		while (pos) {
			blob = (ConData*) thisDEP->condata->GetNext(pos);
			if (blob->description == fileName) {
				fileExist = TRUE;
			}
		}
		if (!fileExist) {
			fo.Delete(depPath + fileName + ".prg");
			fo.Delete(depPath + fileName);
		}
	}
}
void CMyExplorerDoc::GetChildFolders(CStringArray *strFolderList, CString strParentFolder)
{
	// MFC에서 지원되는 파일 검색 객체 
	CFileFind	ff;

	if (strParentFolder.Right(1) != '\\')
	{
		strParentFolder += '\\';
	}

	strParentFolder += "*.*";

	// 주어진 경로의 파일을 찾음 
	if (ff.FindFile(strParentFolder) == TRUE)
	{
		BOOL	bFlag = TRUE;
		while(bFlag == TRUE)
		{
			// 파일이 존재할 경우 다음 파일을 찾을수 
			// 있도록 해준다.
			bFlag = ff.FindNextFile();
			// 파일이 디렉토리이면 0이 아닌 수를 리턴
			// 파일이 '.' 또는 '..'이면 0이 아닌 수를 리턴
			if (ff.IsDirectory() && !ff.IsDots())
				strFolderList->Add(ff.GetFileName());
		}
	}
	ff.Close();
}
Ejemplo n.º 4
0
void CTemplateDialog::CollectTemplateFilesInDirectory(const CString& strDirectory, const CString& strCategory)
{
	//Check, if the name of this subdir exists
	StringTemplateItemArrayMap::iterator it = m_mapSubdirToTemplates.find(strCategory);
	if (it == m_mapSubdirToTemplates.end())
	{
		//Create new entry in map
		it = m_mapSubdirToTemplates.insert(it, std::make_pair(strCategory, CTemplateItemArray()));
	}

	//Parse all files of interest in the directory
	for (int nFilter = 0; nFilter < m_astrFilters.GetSize(); nFilter++)
	{
		CFileFind templates;
		if (!templates.FindFile(strDirectory + "\\" + m_astrFilters[nFilter], 0))
			continue;

		// add all files
		BOOL bTemplatesContinue = TRUE;

		while (bTemplatesContinue)
		{
			bTemplatesContinue = templates.FindNextFile();
			if (!templates.IsDirectory())
			{
				std::unique_ptr<CTemplateItem> pItem
					(dynamic_cast<CTemplateItem*>(m_apTemplateItemClass[nFilter]->CreateObject()));

				if (pItem->InitItem(templates.GetFilePath(), m_ImageList16, m_ImageList32))
					it->second.push_back(std::move(pItem));
			}
		}
		templates.Close();
	}
}
Ejemplo n.º 5
0
BOOL Ccollection::OnInitDialog() 
{
	CDialog::OnInitDialog();
	
	// TODO: Add extra initialization here
		m_list.SetTextColor(RGB(100, 0, 100));
	
	m_list.DeleteAllItems();
	m_list.InsertColumn(0,"标题",LVCFMT_LEFT,200);         //插入列
  
	//m_listnews.InsertColumn(2,"网址",LVCFMT_LEFT,50);
    int i=0;
    CFileFind ff;
    char* path1=new char [10000];
	GetCurrentDirectory(20000,path1);
    path=path1;

    BOOL ret = ff.FindFile(path+"\\RSSCOLLECTION\\*.txt");
    while(ret)
    {
        ret = ff.FindNextFile();
        strPath[i] = ff.GetFileName();
		m_list.InsertItem(0,"");
		m_list.SetItemText(0,0,strPath[i]);
		i++;
    }
    ff.Close();

	article=i;

	return TRUE;  // return TRUE unless you set the focus to a control
	              // EXCEPTION: OCX Property Pages should return FALSE
}
Ejemplo n.º 6
0
void CSkinManager::GetSkinList(CStringArray &skins)
{
	CFileFind finder;
	CString dir = CMyUtility::GetCurDir();
	CString strSkins;
	strSkins.Format(_T("%s\\skins\\*.*"), dir);

	BOOL bFind = finder.FindFile(strSkins);
	if(!bFind)
		return;

	while(bFind)
	{
		bFind = finder.FindNextFile();
		if(finder.IsDots())
			continue;

		if(finder.IsDirectory())
		{
			skins.Add(finder.GetFileName());
			continue;
		}
	}

	finder.Close();

}
BOOL CMyUtils::DeleteDir(LPCTSTR lpDirPath)
{
	CFileFind	finder;
	BOOL		bFind;
	TCHAR		strFindPath[MAX_PATH];

	_stprintf(strFindPath, _T("%s\\*"), lpDirPath);
	bFind = finder.FindFile(strFindPath);
	while (bFind)   
	{
		bFind = finder.FindNextFile();
		if (!finder.IsDirectory())
		{
			if (!DeleteFile(finder.GetFilePath()))
			{
				finder.Close();
				return FALSE;
			}
		}
		else if (!finder.IsDots())
		{
			if (!DeleteDir(finder.GetFilePath()))
			{
				finder.Close();
				return FALSE;
			}
		}
	}
	finder.Close();

	return RemoveDirectory(lpDirPath);
}	
Ejemplo n.º 8
0
void CPropSelUser::resetInformation(void)
{
	CString simg;
	maxUser=0;
	for(int i=0;i<MAX_PEOPLE;i++)
	{
		if(m_pUserItem[i] && m_pUserItem[i]->GameUserInfo.dwUserID!=dwLocalUserID && m_pUserItem[i]->GameUserInfo.dwUserID!=0)
		{
			userRect[maxUser].left=maxUser*100+20;
			userRect[maxUser].top=40;
			userRect[maxUser].right=userRect[maxUser].left+66;//20081128
			userRect[maxUser].bottom=userRect[maxUser].top+105; //20081128
			simg.Format(TEXT("%simage\\log\\log2\\%s\\gamelog%ld.png"),CBcfFile::GetAppPath(),m_pUserItem[i]->GameUserInfo.bBoy?"Boy":"Girl",BzGetAvatarIndex(m_pUserItem[i]));
			if(m_pUserItem[i]->GameUserInfo.bLogoID>=0xFF && m_pUserItem[i]->GameUserInfo.bLogoID<0x200)
			{
				simg.Format("%sCustomFace\\%d.png",CBcfFile::GetAppPath(),m_pUserItem[i]->GameUserInfo.dwUserID);
				CFileFind ff;
				BOOL bFoundFile=ff.FindFile(simg);
				ff.Close();
				if(!bFoundFile)
					simg.Format(TEXT("%simage\\log\\log2\\%s\\gamelog%ld.png"),CBcfFile::GetAppPath(),m_pUserItem[i]->GameUserInfo.bBoy?"Boy":"Girl",0/*m_pUserItem[i]->GameUserInfo.bLogoID%0x100*/);// .bBoy?0:6);// .bLogoID);
			}
#ifndef BZ_ZLIB
			userImg[maxUser]=Image::FromFile(simg.AllocSysString());
#else
			CUnZipRes unZipRes;
			IStream * pStream=NULL;
			TCHAR *pchar=simg.GetBuffer(simg.GetLength()+1);
			pStream=unZipRes.LoadFileResFromZip(pchar);
			userImg[maxUser]=new Image(pStream);
			if(pStream!=NULL)
			{
				pStream->Release();
				pStream=NULL;
			}
#endif

			
			//userRect[maxUser].right=userRect[maxUser].left+(userImg[maxUser]->GetWidth()>0?userImg[maxUser]->GetWidth():50);
			//userRect[maxUser].bottom=userRect[maxUser].top+(userImg[maxUser]->GetHeight()>0?userImg[maxUser]->GetHeight():55);
			userName[maxUser]=m_pUserItem[i]->GameUserInfo.nickName;
			userID[maxUser]=m_pUserItem[i]->GameUserInfo.dwUserID;
			maxUser++;
		}
	}
	CRect r;	//取当前窗口大小
	GetClientRect(&r);
	int x=(r.Width()-maxUser*100)/2; //第一个头像位置
	for(int i=0;i<maxUser;i++)
	{
		userRect[i].left=x+i*100;
		userRect[i].right=userRect[i].left+66;
	}
	//CRect r;
	//GetWindowRect(&r);
	//r.right=r.left+maxUser*100+50;
	//MoveWindow(r);
	//CenterWindow();
}
Ejemplo n.º 9
0
int KGObjectPropertyEditDlg::GetChildPoint(
	HTREEITEM hParent, CString szPath, ENUM_CALL_TYPE nType
)
{
	int nResult  = false;
	int nRetCode = false;

	ASSERT(hParent);

	HTREEITEM hChild;
	KG_PROCESS_ERROR(szPath != "");

	if (nType == TYPE_FIRST)
	{
		hChild = hParent;
	}
	else
	{
		hChild = m_treeObjectView.GetChildItem(hParent);
	}

	while (hChild)
	{
		CString strText = m_treeObjectView.GetItemText(hChild);
		if (strText.Right(1) != "\\")
		{
			strText += _T("\\");
		}

		CFileFind file;
		BOOL bContinue = file.FindFile(szPath + strText + "*.*");

		while (bContinue)
		{
			bContinue = file.FindNextFile();
			if (file.IsDirectory() && !file.IsDots())
 			{
				m_treeObjectView.InsertItem(file.GetFileName(), hChild);
			}
			else if (file.GetFileName().Right(4) == ".ini")
			{
				char szName[MAX_TEXT];
				strncpy(
					szName, file.GetFileName().GetBuffer(), sizeof(szName)
				);
				szName[sizeof(szName) - 1] = '\0';
				m_treeObjectView.InsertItem(szName, hChild);
			}
		}

		file.Close();
		GetChildPoint(hChild, szPath + strText, TYPE_OTHER);
		hChild = m_treeObjectView.GetNextItem(hChild, TVGN_NEXT);
	}

	nResult = true;
Exit0:
	return nResult;
}
void CSpritePage::OnAddFrame() 
{
	CString ret = "";
	CBGame* Game = m_View->m_Sprite->Game;

	CString InitFile="";
	if(m_View->m_SelectedSubframe) InitFile = m_View->m_SelectedSubframe->m_Surface->m_Filename;

	// make absolute path
	Game->m_FileManager->RestoreCurrentDir();
	for(int i=0; i<Game->m_FileManager->m_SinglePaths.GetSize(); i++){
		CString NewPath = CString(Game->m_FileManager->m_SinglePaths[i]) + InitFile;
		CFileFind finder;
		if(finder.FindFile(NewPath)){
			InitFile = NewPath;
			break;
		}
	}

	CString Filter = "Image files (*.bmp; *.tga; *.png; *.jpg)|*.bmp;*.tga;*.png;*.jpg|All Files (*.*)|*.*||";
	CFileDialog dlg(TRUE, NULL, InitFile, OFN_ALLOWMULTISELECT|OFN_HIDEREADONLY|OFN_ENABLESIZING|OFN_FILEMUSTEXIST|OFN_PATHMUSTEXIST|OFN_NOCHANGEDIR, Filter, this);
	char NameBuffer[32768+1] = "";
	dlg.m_ofn.lpstrFile = NameBuffer;
	dlg.m_ofn.nMaxFile = 32768;
	if(InitFile=="") InitFile = CString(Game->m_FileManager->m_BasePath);
	dlg.m_ofn.lpstrInitialDir = LPCSTR(InitFile);
	
	if(dlg.DoModal()==IDOK){
		m_View->SetUndoState("Add frame(s)");
		POSITION pos = dlg.GetStartPosition();
		while(pos){
			CString filename = dlg.GetNextPathName(pos);
			char* str = new char[filename.GetLength()+1];
			strcpy(str, LPCSTR(filename));
			Game->m_FileManager->MakeRelativePath(str);

			CBSurface* surf = Game->m_SurfaceStorage->AddSurface(str);
			if(surf){
				CBFrame* frame = ::new CBFrame(Game);
				CBSubFrame* subframe = ::new CBSubFrame(Game);
				subframe->m_Surface = surf;
				subframe->SetDefaultRect();
				frame->m_Subframes.Add(subframe);

				int i = m_View->m_Sprite->m_CurrentFrame+1;
				if(i<m_View->m_Sprite->m_Frames.GetSize())
					m_View->m_Sprite->m_Frames.InsertAt(i, frame);
				else{
					m_View->m_Sprite->m_Frames.Add(frame);					
				}
				m_View->m_Sprite->m_CurrentFrame=i;
				m_View->m_SelectedSubframe = subframe;
			}
			else MessageBox("Error loading image \"" + filename + "\".", NULL, MB_OK|MB_ICONERROR);
			delete [] str;
		}
		Redraw();
	}
}
Ejemplo n.º 11
0
BOOL Directory::IsValidFile()
{
    CFileFind fileFind;
    if (!fileFind.FindFile(m_pathToValidate))
        return FALSE;

    return TRUE;
}
Ejemplo n.º 12
0
DWORD CSetupApp::GetFilesToCopy(CStringArray& files)
{
	files.RemoveAll();

	ULONGLONG total= 0;

	CFileFind finder;

	BOOL b= finder.FindFile(GetAppFolder() + _T("\\windirstat.*"));
	while (b)
	{
		b= finder.FindNextFile();
		if (finder.IsDirectory())
			continue;
		files.Add(finder.GetFilePath());
                // Retrieve file size
		total+= finder.GetLength();
	}
	finder.Close();

	b= finder.FindFile(GetAppFolder() + _T("\\wdsr*.dll"));
	while (b)
	{
		b= finder.FindNextFile();
		if (finder.IsDirectory())
			continue;
		files.Add(finder.GetFilePath());
		// Retrieve file size
                total+= finder.GetLength();
	}
	finder.Close();

	b= finder.FindFile(GetAppFolder() + _T("\\wdsh*.chm"));
	while (b)
	{
		b= finder.FindNextFile();
		if (finder.IsDirectory())
			continue;
		files.Add(finder.GetFilePath());
		// Retrieve file size
                total+= finder.GetLength();
	}
	finder.Close();

	return (DWORD)total;
}
Ejemplo n.º 13
0
void RemoveFile( const CString& filePath )
{
    CFileFind ff;
    if( ff.FindFile( filePath ) )
    {
        CFile::Remove( filePath );
    }
}
Ejemplo n.º 14
0
BOOL CPathUtilEx::IsFileExist(const CString& strFile)
{
	CFileFind finder;
	BOOL bExist = finder.FindFile(strFile);
	finder.Close();

	return bExist;
}
Ejemplo n.º 15
0
bool FolderExists(LPCTSTR path)
{
    CFileFind finder;
    BOOL b = finder.FindFile(path);
    if(b)
    {
        finder.FindNextFile();
        return (FALSE != finder.IsDirectory());
    }
    else
    {
        // Here we land, if path is an UNC drive. In this case we
        // try another FindFile:
        b = finder.FindFile(CString(path) + _T("\\*.*"));
        return (b != false);
    }
}
Ejemplo n.º 16
0
void CTrainDlg::OnBnClickedInputNegetive()
{
	// TODO: 在此添加控件通知处理程序代码
	
	m_negetive.Empty();
	BROWSEINFO bi;  
	char name[MAX_PATH];  
	ZeroMemory(&bi,sizeof(BROWSEINFO));  
	bi.hwndOwner = GetSafeHwnd();  
	bi.pszDisplayName = name;  
	bi.lpszTitle = "选择负样本文件夹";  
	//bi.ulFlags = BIF_USENEWUI;  
	bi.ulFlags = BIF_RETURNFSANCESTORS;  
	LPITEMIDLIST idl = SHBrowseForFolder(&bi);  
	if(idl != NULL)  
	{
		SHGetPathFromIDList(idl, m_negetive.GetBuffer(MAX_PATH));  
		m_negetive.ReleaseBuffer();
		UpdateData(FALSE);
	 }

	//产生负样本描述文件
	CString filePath;
	filePath.Format("%s\\bg.txt",m_negetive.Mid(0,m_negetive.ReverseFind('\\')));
	CFile file(filePath,CFile::modeCreate | CFile::modeWrite);
	
	m_bg = filePath;
	m_iNegetiveNum = 0;

	CString direName = m_negetive.Mid(m_negetive.ReverseFind('\\')+1,m_negetive.GetLength()-m_negetive.ReverseFind('\\')-1);

    CFileFind finder;  
    BOOL bWorking = finder.FindFile(m_negetive+"\\*.*");  
    while(bWorking)  
    {  
	    bWorking=finder.FindNextFile();  
		CString str;
		if(finder.GetFileName() != '.' && finder.GetFileName() != "..")
		{
			if(bWorking)
			{
				str.Format("%s\\%s\r\n",direName,finder.GetFileName());
			}
			else
			{
				str.Format("%s\\%s",direName,finder.GetFileName());
			}
			file.Write(str,str.GetLength());
			m_iNegetiveNum++;
		}
	}  
	UpdateData(FALSE);
	file.Close();
	finder.Close();

	MessageBox("负样本文件夹:"+m_negetive);

}
Ejemplo n.º 17
0
void CUIControler::OnOpenTestSuite()
{
	CString m_strSelectedFolder;
	if (!theApp.GetShellManager()->BrowseForFolder(m_strSelectedFolder, AfxGetMainWnd(), m_strSelectedFolder))
		return;
	

	std::string folderPath=CCommonUtilities::toBasicString(m_strSelectedFolder);
	//
	for (foldersVectorT::iterator myIt=foldersVector.begin();
		myIt!=foldersVector.end();myIt++)
	{
		std::string thisFolderPath=*myIt;
		if (thisFolderPath==folderPath)
		{
			AfxMessageBox(_T("Already opened, choose update instead"));
			return;
		}
	}


	CStringArray files;

	CFileFind finder;
	BOOL bWorking = finder.FindFile(m_strSelectedFolder+_T("/*.xml"));
	while (bWorking)
	{
		bWorking = finder.FindNextFile();
		files.Add(finder.GetFilePath());
	} 

	if (files.GetCount()!=0)
	{
		HTREEITEM hSuiteItem=pHistoryTree->createSuiteTreeItem(m_strSelectedFolder);
		foldersVector.push_back(folderPath);
		addFolderToHomeCombo(m_strSelectedFolder);
		//
		for (int i=0;i<files.GetCount();i++)
		{
			std::string filePath=CCommonUtilities::toBasicString(files[i]);

			testsFilesMapT::iterator myIt=testsFilesMap.find(filePath);
			if(myIt==testsFilesMap.end())
			{
				CTestsFile* pTests=openFile(filePath);
				if (pTests)
				{
					pTests->setParentFolder(folderPath);
					pHistoryTree->renderFile(pTests,hSuiteItem);
				}
			}	
		}
	}
	else
	{
		AfxMessageBox(_T("Folder is empty"));
	}	
}
Ejemplo n.º 18
0
/**
 * Sets the style file
 *
 * \param xsldoc Either a filename or source of XSL file
 */
void CXSLTransform::SetXSLDoc(CString xsldoc)
{
	if (m_XSLDoc.Compare(xsldoc) != 0) {
		m_XSLDoc = xsldoc;
		Reset();
		if (xsldoc.IsEmpty()) {
			return;
		}
		xmlErrorPtr err = NULL;

		xmlDocPtr xsl = NULL;
		CFileFind ff;
		if (xsldoc.GetLength() < MAX_PATH && ff.FindFile(xsldoc)) {
			// xsldoc is a filename
			ff.Close();
			m_Style = xsltParseStylesheetFile((const xmlChar *)(LPCSTR)xsldoc);
			if (!m_Style || m_Style->errors > 0) {
				xmlFreeDoc(xsl);
				err = xmlGetLastError();
				if (err != NULL)
					m_LastError.Format(AfxLoadString(IDS_STRING_XSLPARSEERR), err->file, err->line, err->int2, err->code, err->message);
				else
					m_LastError.LoadString(IDS_STRING_UNKNOWN_XSLERROR);
				xmlResetLastError();
#ifdef _DEBUG
				TRACE1("CXSLTransform::SetXSLDoc(): %s\n", m_LastError);
#endif
			}
		} else {
			// xsldoc is a XSL source
			xsl = xmlParseMemory(xsldoc, xsldoc.GetLength());
			if (xsl) {
				m_Style = xsltParseStylesheetDoc(xsl);
				if (!m_Style || m_Style->errors > 0) {
					xmlFreeDoc(xsl);
					err = xmlGetLastError();
					if (err != NULL)
						m_LastError.Format(AfxLoadString(IDS_STRING_XSLPARSEERR), err->file, err->line, err->int2, err->code, err->message);
					else
						m_LastError.LoadString(IDS_STRING_UNKNOWN_XSLERROR);
					xmlResetLastError();
#ifdef _DEBUG
					TRACE1("CXSLTransform::SetXSLDoc(): %s\n", m_LastError);
#endif
				}
			} else {
				// XML parsing error
				err = xmlGetLastError();
				m_LastError.Format(AfxLoadString(IDS_STRING_XMLPARSEERR), err->file, err->line, err->int2, err->code, err->message);
				xmlResetLastError();
#ifdef _DEBUG
				TRACE1("CXSLTransform::SetXSLDoc(): %s\n", m_LastError);
#endif
			}
		}
	}
}
Ejemplo n.º 19
0
CString COptions::FindFile(CString name)
{
    CFileFind finder;
    CString res;
    res.Format(_T("%s%s"), AddBackslash(GetAppPath()), name);
    BOOL found = finder.FindFile(res);
    if (!found)	{
        res.Format(_T("%s..\\%s"), AddBackslash(GetAppPath()), name);
        found = finder.FindFile(res);
        if (!finder.FindFile(res)) {
            res.Format(_T("%s..\\doc\\%s"), AddBackslash(GetAppPath()), name);
            if (!finder.FindFile(res))
                res.Empty();
        }
    }
    finder.Close();
    return res;
}
Ejemplo n.º 20
0
void CUIControler::OnUpdateFileFolder()
{
	CMainFrame* pMainFrame=(CMainFrame*)AfxGetMainWnd();
	CMFCRibbonComboBox* pFileFoldersCombo = DYNAMIC_DOWNCAST(CMFCRibbonComboBox,pMainFrame->GetRibbonBar()->FindByID(WM_SELECT_FILEFOLDER));


	if (pFileFoldersCombo->GetCurSel()==-1)
		return;

	CString strPath=pFileFoldersCombo->GetItem(pFileFoldersCombo->GetCurSel());

	if ( pFileFoldersCombo->GetItemData(pFileFoldersCombo->GetCurSel())==0 )
	{
		AfxMessageBox(_T("Updating Folder :\n")+strPath);
		//It is a folder.
		std::string folderPath=CCommonUtilities::toBasicString(strPath);

		HTREEITEM hSuiteItem=pHistoryTree->findSuiteTreeItem(folderPath);

		CFileFind finder;
		BOOL bWorking = finder.FindFile(strPath+_T("/*.xml"));
		while (bWorking)
		{
			bWorking = finder.FindNextFile();
			std::string filePath=CCommonUtilities::toBasicString(finder.GetFilePath());
			//
			testsFilesMapT::iterator myIt=testsFilesMap.find(filePath);
			if(myIt==testsFilesMap.end())
			{
				CTestsFile* pTests=openFile(filePath);
				if (pTests)
				{
					pTests->setParentFolder(folderPath);
					pHistoryTree->renderFile(pTests,hSuiteItem);
				}
			}
		} 
		return;
	}
	else
	{
		AfxMessageBox(_T("Updating File :\n")+strPath);
		std::string filePath=CCommonUtilities::toBasicString(strPath);
		//Close the file then reopen it :
		CloseTestsFile(filePath);
		
		//Reopen it :

		CTestsFile* pTests=openFile(filePath);
		if (pTests)
		{
			pHistoryTree->renderFile(pTests,pHistoryTree->hRoot);
			addFileToHomeCombo(strPath);
		}

	}
}
void CRootDlg::OnOK() 
{
	CString result;

	if(m_BtnPrev.GetCheck()){
		m_PrevList.GetText(m_PrevList.GetCurSel(), result);
	}
	else{
		m_CustomName.GetWindowText(result);
		if(result==""){
			MessageBeep(MB_ICONERROR);
			return;
		}

		char full[MAX_PATH];
		_fullpath(full, LPCSTR(result), MAX_PATH);
		result = CString(full);

		result.Replace('/', '\\');
		if(result[result.GetLength()-1]!='\\') result += '\\';
		m_CustomName.SetWindowText(result);
	}

	// check whether the filename lies within this folder
	if(m_Filename!=""){
		CString filename = m_Filename;
		filename.Replace('/', '\\');
		if(result!=filename.Left(result.GetLength())){
			MessageBox("Folder '" + result + "' is not a parent folder of file '" + m_Filename + "'.", "Error", MB_ICONERROR);
			return;
		}
	}


	DWORD attr = GetFileAttributes(LPCSTR(result));
	if(attr == 0xFFFFFFFF || (attr & FILE_ATTRIBUTE_DIRECTORY) == 0){
		if(MessageBox("Folder '" + result + "' doesn't exist.\nDo you want to create it?", NULL, MB_ICONQUESTION|MB_OKCANCEL)!=IDOK) return;

		result = MakePath(result);
		if(result==""){
			MessageBox("The specified folder cannot be created.", "Error", MB_ICONERROR);
			return;
		}
	}

	CFileFind finder;
	if(!finder.FindFile(result + "*.wpr")){
		if(MessageBox("This doesn't appear to be a valid root folder (no project file was found).\n\nDo you want to continue anyway?", "Warning", MB_ICONWARNING|MB_YESNO)!=IDYES) return;
	}
	

	m_SelectedFolder = result;

	
	CDialog::OnOK();
}
Ejemplo n.º 22
0
bool IniTool::SetFilePath(CString sFilePath)
{
	CFileFind finder;
	if(FALSE == finder.FindFile(sFilePath))
		return false;

	m_sFilePath = sFilePath;

	return true;
}
Ejemplo n.º 23
0
void CMainFrame::MakeLong(CString &DirName)
{
	CFileFind find;
	BOOL found=find.FindFile(DirName+_T("\\."));
	if (found)
	{
		find.FindNextFile();
		DirName=find.GetFilePath();
	}
}
Ejemplo n.º 24
0
bool CUploadTask::DeleteMultipartFile()
{
	if (m_FileIndex.m_hFile!=CFile::hFileNull)
		m_FileIndex.Close();
	wstring multipartpath=wstring(GetStaroneControl()->GetTransCache())+m_Item.strUploadId;
	CFileFind filefind;
	if (filefind.FindFile(multipartpath.c_str()))
		DeleteFile(multipartpath.c_str());
	return true;
}
Ejemplo n.º 25
0
// ----------------------------------------------------------------------------
//
void DefinitionReader::readFixtureDefinitions( LPCSTR directory )
{
    CFileFind finder;
    
    CString directory_search( directory );
    directory_search.Append( "\\*" );

    BOOL working = finder.FindFile( directory_search );
    if ( !working ) 
        throw StudioException( "Unable to find fixture definition directory '%s'", directory );

    while ( working ) {
        working = finder.FindNextFile();
        if ( finder.IsDots() )
            continue;

        CString file_name = finder.GetFilePath();
        if ( finder.IsDirectory() )
            readFixtureDefinitions( file_name );

        CString test_name( file_name );
        if ( test_name.MakeLower().Find( ".xml" ) == -1 )
            continue;

        // Check for definition file
        TiXmlDocument doc;
        if ( !doc.LoadFile( file_name ) )
            throw StudioException( "Error reading fixture definition '%s'", file_name );

        try {
            TiXmlElement* root = doc.FirstChildElement( "fixture_definitions" );
            LPCSTR author = read_text_element( root, "author" );
            LPCSTR version = read_text_element( root, "version" );

            FixtureDefinitionPtrArray fixture_definitions = read_xml_list<FixtureDefinition>( root, "fixture" );

            //DefinitionWriter writer;
            //writer.writeFixtureDefinition( file_name, author, version, fixture_definitions );

            for ( FixtureDefinition* definition : fixture_definitions ) {
                definition->setSourceFile( file_name );
                definition->m_author = author;
                definition->m_version = version;

                FixtureDefinition::addFixtureDefinition( definition );
                delete definition;
            }
        }
        catch ( StudioException e ) {
            throw StudioException( "%s: %s", file_name, e.what() );
        }
    }
    
    finder.Close();
}
Ejemplo n.º 26
0
void CTrainDlg::OnBnClickedNormal()
{
	// TODO: 在此添加控件通知处理程序代码
	

	//产生正样本描述文件
	CString filePath;
	filePath.Format("%s\\info.dat",m_positive.Mid(0,m_positive.ReverseFind('\\')));
	CFile file(filePath,CFile::modeCreate | CFile::modeWrite);
	
	m_info = filePath;
	m_vec.Format("%s\\positive.vec",m_positive.Mid(0,m_positive.ReverseFind('\\')));
	m_data.Format("%s\\result",m_positive.Mid(0,m_positive.ReverseFind('\\')));
	m_iPositiveNum = 0;
	m_iImgWidth = 24;
	m_iImgHeight = 24;

	CString direName = m_positive.Mid(m_positive.ReverseFind('\\')+1,m_positive.GetLength()-m_positive.ReverseFind('\\')-1);

    CFileFind finder;  
    BOOL bWorking = finder.FindFile(m_positive+"\\*.*");  
    while(bWorking)  
    {  
	    bWorking=finder.FindNextFile();  
		CString str;
		if(finder.GetFileName() != '.' && finder.GetFileName() != "..")
		{
			//将正样本同一转换为 24*24大小的文件
			IplImage* src;
			if( (src = cvLoadImage(finder.GetFilePath(),CV_LOAD_IMAGE_ANYDEPTH | CV_LOAD_IMAGE_ANYCOLOR))!= 0)
			{
				IplImage* small_img = cvCreateImage(cvSize(24,24),src->depth,src->nChannels);
				cvResize( src, small_img, CV_INTER_LINEAR );
				cvSaveImage(finder.GetFilePath(),small_img);
				if(bWorking)
				{
					str.Format("%s\\%s 1 0 0 24 24\r\n",direName,finder.GetFileName());
				}
				else
				{
					str.Format("%s\\%s 1 0 0 24 24",direName,finder.GetFileName());
				}
				file.Write(str,str.GetLength());
				m_iPositiveNum++;
				
				cvReleaseImage( &small_img );
			}
			cvReleaseImage( &src );
		}
	}  
	UpdateData(FALSE);
	file.Close();
	finder.Close();
	MessageBox("样本归一化成功");
}
Ejemplo n.º 27
0
void InputPlugin::listDllFiles() {

	//==========================
	CFileFind	cFileFind;
	CString		searchFile;
	BOOL		found;
	BOOL		foundMatch;			// match with the ini config
	bool		canRecord;
	CString		temp;
	int			i;
	int			matchIndex;
	//==========================

	searchFile	= _T(".\\*.dll");
	found		= cFileFind.FindFile(searchFile);
	foundMatch	= FALSE;
	i			= 0;
	matchIndex	= 0;
	canRecord	= false;

	if(!found) {

		MessageBox(_T("No valid dlls found."));

		return;
	}

	while(found) {

		found = cFileFind.FindNextFile();

		if(checkDllFile(cFileFind.GetFilePath())) {

			m_cboxInputPlugin.AddString(cFileFind.GetFileName());
		
			if(cFileFind.GetFileName() == config.plugin) {
				m_cboxInputPlugin.SetCurSel(i);
				foundMatch	= TRUE;
				matchIndex	= i;
				canRecord	= checkRecording(cFileFind.GetFilePath());
			}
			
			i++;
		}
	}

	m_cboxInputPlugin.SetCurSel(matchIndex);
	m_cboxInputPlugin.GetLBText(matchIndex,temp);

	temp = _T(".\\") + temp;

	loadDll(temp);
	enableWindows(canRecord);
}
Ejemplo n.º 28
0
 int CheckDB(char* pDb)
 {
  CFileFind finder;
  char loc[256];
  strcpy(loc,"..\\Data\\");
  strcat(loc,pDb);
  int  bWorking = finder.FindFile(loc);
  int iNameLen = 0,iTemp = 0;

  return bWorking;
 }
Ejemplo n.º 29
0
void CAddLinksDlg::initNodes()
{
	const CString notFound=_T("");
	const CString sectionNode=_T("NodeInfo");
	CFileFind finder;
	CString configPath;
	CString valueStr;
	CString comboItemStr=_T("");
	bool isFound=finder.FindFile(_T(".\\*.ini"));
	while(isFound)
	{
		comboItemStr=_T("");
		isFound=finder.FindNextFile();
		configPath=_T(".\\")+finder.GetFileName();
		if(configPath.Find(_T("config["))<0)
		{
			continue;
		}
		::GetPrivateProfileString(sectionNode,_T("LinkType"),notFound,valueStr.GetBuffer(MAX_PATH),MAX_PATH,configPath);
		valueStr.ReleaseBuffer();
		if(valueStr!=notFound)
		{
			continue;
		}
		::GetPrivateProfileString(sectionNode,_T("DstNode"),notFound,valueStr.GetBuffer(MAX_PATH),MAX_PATH,configPath);
		valueStr.ReleaseBuffer();
		if(valueStr!=notFound)
		{
			continue;
		}
		::GetPrivateProfileString(sectionNode,_T("NodeID"),notFound,valueStr.GetBuffer(MAX_PATH),MAX_PATH,configPath);
		valueStr.ReleaseBuffer();
		comboItemStr+=_T("节点 ")+valueStr;
		::GetPrivateProfileString(sectionNode,_T("NodeType"),notFound,valueStr.GetBuffer(MAX_PATH),MAX_PATH,configPath);
		valueStr.ReleaseBuffer();
		comboItemStr+=_T("(")+valueStr+_T(")");

		m_ComboNode1.AddString(comboItemStr);
		m_ComboNode2.AddString(comboItemStr);
		//int intfMACHex=GetPrivateProfileInt(sectionNode,_T("IntfMAC"),0,configPath);
		//valueStr.Format(_T("%012X"),intfMACHex);
		////::GetPrivateProfileString(sectionNode,_T("IntfMac"),notFound,valueStr.GetBuffer(MAX_PATH),MAX_PATH,configPath);
		////valueStr.ReleaseBuffer();
		//m_ListNodes.SetItemText(count,2,valueStr);
	}
	if (m_ComboNode1.GetCount()==0)
	{
		m_ComboNode1.AddString(_T("无未配置节点"));
	}
	if (m_ComboNode2.GetCount()==0)
	{
		m_ComboNode2.AddString(_T("无未配置节点"));
	}
}
Ejemplo n.º 30
0
void CDirTreeCtrl::DisplayPath(HTREEITEM hParent, LPCTSTR strPath)
{
	//
	// Displaying the Path in the TreeCtrl
	//
	CFileFind find;
	CString   strPathFiles = strPath;
	BOOL      bFind;
	CSortStringArray strDirArray;
	CSortStringArray strFileArray;
	
	if ( strPathFiles.Right(1) != _T("\\") )
		strPathFiles += _T("\\");
	strPathFiles += _T("*.*");

	bFind = find.FindFile( strPathFiles );

	while ( bFind )
	{
		bFind = find.FindNextFile();
		if ( find.IsDirectory() && !find.IsDots() )
		{		
			strDirArray.Add( find.GetFilePath() );
		}
		if ( !find.IsDirectory() && m_bFiles )
			strFileArray.Add( find.GetFilePath() );

	}
    
	strDirArray.Sort();
	SetRedraw( FALSE );
	CWaitCursor wait;
    
	for ( int i = 0; i < strDirArray.GetSize(); i++ )
	{
			HTREEITEM hItem = AddItem( hParent, strDirArray.GetAt(i) );
			if ( FindSubDir( strDirArray.GetAt(i) ) )
				InsertItem( _T(""), 0, 0, hItem );
	}

	if ( m_bFiles )
	{
		strFileArray.Sort();
		for (int i = 0; i < strFileArray.GetSize(); i++ )
		{
			HTREEITEM hItem = AddItem( hParent, strFileArray.GetAt(i) );
			
		}
	}
    
	SetRedraw( TRUE );

	
}