Пример #1
0
int CFileName::FindFiles (LPCTSTR pszDir,CFileNameArray &ar,LPCTSTR pszPattern/*=_T("*.*")*/,bool bRecurse/*=true*/,DWORD dwExclude/*=FILE_ATTRIBUTE_DIRECTORY|FILE_ATTRIBUTE_HIDDEN*/)
{
  ar.RemoveAll();
  CFileFind finder;
  BOOL bMore=finder.FindFile(CFileName(pszDir)+pszPattern);
  while (bMore)    {
    bMore = finder.FindNextFile();
    if(!finder.IsDots() && !finder.MatchesMask(dwExclude)){
      CFileName strFile(finder.GetFilePath());
      ar.Add(strFile);
    }
  }
  if(bRecurse){
    CFileFind finder;
    BOOL bMore=finder.FindFile(CFileName(pszDir)+_T("*.*"));
    while (bMore)    {
      bMore = finder.FindNextFile();
      if(!finder.IsDots() && finder.IsDirectory()){
        CFileNameArray ar2;
        FindFiles(finder.GetFilePath(),ar2,pszPattern,bRecurse,dwExclude);
        ar.Append(ar2);
      }
    }
  }
  return ar.GetSize();
}
Пример #2
0
void DirRecurs(LPCTSTR pstr)
{
	CFileFind finder;

	CString sz_wildcard(pstr);
	sz_wildcard += _T("\\*.*");

	BOOL bResult = finder.FindFile(sz_wildcard);
	while (bResult)
	{
		bResult = finder.FindNextFile();

		//skip . and .. files; otherwise, recur infinitely!
		CString temp = finder.GetFilePath();
		cout << (LPCTSTR)temp << endl;

		if (finder.IsDots())
			continue;

		//if it's a directory , recursively search it
		if (finder.IsDirectory())
		{
			CString str = finder.GetFilePath();
			//cout << (LPCTSTR)str << endl;
			//DirRecurs(str);
		}
	}
	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);
}	
Пример #4
0
void CDirstatDoc::RecursiveUserDefinedCleanup(const USERDEFINEDCLEANUP *udc, const CString& rootPath, const CString& currentPath)
{
    // (Depth first.)

    CFileFind finder;
    BOOL b = finder.FindFile(currentPath + _T("\\*.*"));
    while(b)
    {
        b = finder.FindNextFile();
        if((finder.IsDots()) || (!finder.IsDirectory()))
        {
            continue;
        }
        if(GetWDSApp()->IsVolumeMountPoint(finder.GetFilePath()) && !GetOptions()->IsFollowMountPoints())
        {
            continue;
        }
        if(GetWDSApp()->IsFolderJunction(finder.GetFilePath()) && !GetOptions()->IsFollowJunctionPoints())
        {
            continue;
        }

        RecursiveUserDefinedCleanup(udc, rootPath, finder.GetFilePath());
    }

    CallUserDefinedCleanup(true, udc->commandLine, rootPath, currentPath, udc->showConsoleWindow, true);
}
Пример #5
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);
}
Пример #6
0
void CNifConvertDlg::parseDir(CString path, set<string>& directories, bool doDirs)
{
	CFileFind   finder;
	BOOL        result(FALSE);

	result = finder.FindFile(path + _T("\\*.*"));

	while (result)
	{
		result = finder.FindNextFileW();

		if (finder.IsDots())    continue;
		if (finder.IsDirectory() && doDirs)
		{
			CString   newDir(finder.GetFilePath());
			CString   tDir = newDir.Right(newDir.GetLength() - newDir.Find(_T("\\Textures\\")) - 1);

			directories.insert(CStringA(tDir).GetString());

			parseDir(newDir, directories);
		}
		else if (!finder.IsDirectory() && !doDirs)
		{
			CString   newDir(finder.GetFilePath());
			CString   tDir = newDir.Right(newDir.GetLength() - path.GetLength() - 1);

			directories.insert(CStringA(tDir).GetString());
		}
	}
}
Пример #7
0
int CPartFileConvert::ScanFolderToAdd(CString folder,bool deletesource) {
	int count=0;
	CFileFind finder;
	BOOL bWorking;

	bWorking = finder.FindFile(folder+_T("\\*.part.met"));
	while (bWorking) {
		bWorking=finder.FindNextFile();
		ConvertToeMule(finder.GetFilePath(),deletesource);
		count++;
	}
	// Shareaza
	bWorking = finder.FindFile(folder+_T("\\*.sd"));
	while (bWorking) {
		bWorking=finder.FindNextFile();
		ConvertToeMule(finder.GetFilePath(),deletesource);
		count++;
	}


	bWorking = finder.FindFile(folder+_T("\\*.*"));
	while (bWorking) {
        bWorking = finder.FindNextFile();
		CString test=finder.GetFilePath();
		if (finder.IsDirectory() && finder.GetFileName().Left(1)!=_T("."))
			count += ScanFolderToAdd(finder.GetFilePath(),deletesource);
	}

	return count;
}
Пример #8
0
void InformApp::FindExtensions(void)
{
  m_extensions.clear();
  for (int i = 0; i < 2; i++)
  {
    CString path;
    switch (i)
    {
    case 0:
      path.Format("%s\\Internal\\Extensions\\*.*",(LPCSTR)GetAppDir());
      break;
    case 1:
      path.Format("%s\\Inform\\Extensions\\*.*",(LPCSTR)GetHomeDir());
      break;
    default:
      ASSERT(FALSE);
      break;
    }

    CFileFind find;
    BOOL finding = find.FindFile(path);
    while (finding)
    {
      finding = find.FindNextFile();
      if (!find.IsDots() && find.IsDirectory())
      {
        CString author = find.GetFileName();
        if (author == "Reserved")
          continue;
        if ((author.GetLength() > 0) && (author.GetAt(0) == '.'))
          continue;

        path.Format("%s\\*.*",(LPCSTR)find.GetFilePath());
        CFileFind find;
        BOOL finding = find.FindFile(path);
        while (finding)
        {
          finding = find.FindNextFile();
          if (!find.IsDirectory())
          {
            CString ext = ::PathFindExtension(find.GetFilePath());
            if (ext.CompareNoCase(".i7x") == 0)
              m_extensions.push_back(ExtLocation(author,find.GetFileTitle(),(i == 0),find.GetFilePath()));
            else if (ext.IsEmpty() && (i == 1))
            {
              // Rename an old-style extension (with no file extension) to end with ".i7x"
              CString newPath = find.GetFilePath();
              newPath.Append(".i7x");
              if (::MoveFile(find.GetFilePath(),newPath))
                m_extensions.push_back(ExtLocation(author,find.GetFileTitle(),(i == 0),newPath));
            }
          }
        }
        find.Close();
      }
    }
    find.Close();
  }
  std::sort(m_extensions.begin(),m_extensions.end());
}
Пример #9
0
void CTableMapLoader::ParseAllTableMapsToLoadConnectionData(CString TableMapWildcard)
{
	CFileFind	hFile;
	SWholeMap	smap;
	int			line = 0;

	write_log(prefs.debug_tablemap_loader(), "[CTablemapLoader] ParseAllTableMapsToLoadConnectionData: %s\n", TableMapWildcard);
	_number_of_tablemaps_loaded = 0;
	CString	current_path = p_tablemap->filepath();
	BOOL bFound = hFile.FindFile(TableMapWildcard.GetString());
	while (bFound)
	{
		if (_number_of_tablemaps_loaded >= k_max_nmber_of_tablemaps)
		{
			write_log(prefs.debug_tablemap_loader(), "[CTablemapLoader] CAutoConnector: Error: Too many tablemaps. The autoconnector can only handle 25 TMs.", "Error", 0);
			OH_MessageBox("To many tablemaps.\n"
				"The auto-connector can handle 25 at most.", "ERROR", 0);
			return;
		}
		bFound = hFile.FindNextFile();
		if (!hFile.IsDots() && !hFile.IsDirectory() && hFile.GetFilePath()!=current_path)
		{
			int ret = p_tablemap->LoadTablemap((char *) hFile.GetFilePath().GetString(), 
				VER_OPENSCRAPE_2, &line);
			if (ret == SUCCESS)
			{
				CTableMapToSWholeMap(p_tablemap, &smap);
				ExtractConnectionDataFromCurrentTablemap(&smap);
				write_log(prefs.debug_tablemap_loader(), "[CTablemapLoader] Number of TMs loaded: %d\n", _number_of_tablemaps_loaded);
			}
		}
	}
}
Пример #10
0
BOOL CEncryptFile::DecryptDir(CString strKey, CString strSrcDir, CString strDstDir, CProgressCtrl *pCtal)
{
	//AfxMessageBox("创建文件夹"+target);    
	CFileFind finder;
	CString stPath;
	BOOL re = FALSE;
	stPath.Format(_T("%s/*.*"), strSrcDir);
	BOOL bWorking = finder.FindFile(stPath);
	while (bWorking)
	{
		bWorking = finder.FindNextFile();
		if (finder.IsDirectory() && !finder.IsDots())//是文件夹 而且 名称不含 . 或 ..    
		{
			//递归解密+"/"+finder.GetFileName()  
			DecryptDir(strKey, finder.GetFilePath(), strDstDir + _T("\\") + finder.GetFileName(), pCtal);
		}
		else//是文件 则直接解密   
		{
			CString stSrcFile = finder.GetFilePath();
			BOOL result = (GetFileAttributes(stSrcFile) & FILE_ATTRIBUTE_DIRECTORY);
			if (!result)
			{
				re = DecryptFile(strKey, finder.GetFilePath(), strDstDir + _T("\\") + finder.GetFileName());
				pCtal->StepIt();
			}
		}
	}
	return TRUE;
} 
Пример #11
0
BOOL CDirTreeCtrl::BuildTree(HTREEITEM hParent,LPCTSTR strPath)
{      
	CFileFind find;
	HTREEITEM parent;
	CString   strTemp = strPath;
	BOOL      bFind;
	if ( strTemp.Right(1) == _T('\\') ){
		strTemp += _T("*.*");
	}else{
		strTemp += _T("\\*.*");
	}
	bFind = find.FindFile( strTemp );

	while ( bFind ) {
		bFind = find.FindNextFile();

		if ( find.IsDirectory()){
			if(!find.IsDots()){
				parent = AddItem1(hParent, find.GetFilePath(), find.GetFileName());
				BuildTree(parent, find.GetFilePath());
			}
		}else{
			AddItem1(hParent, find.GetFilePath(), find.GetFileName());
		}
	}
	
	return TRUE; 
}
Пример #12
0
void MusicUtils::EmptyDir(CString Dir)
{
	CFileFind finder;
	CFile cfile;
	CString Add=L"\\*";
	CString DirSpec=Dir+Add;                        //????????????
	BOOL bWorking = finder.FindFile(DirSpec);


	while (bWorking)
	{
		bWorking = finder.FindNextFile();

		if(!finder.IsDots())              //????????
		{
			if(finder.IsDirectory())           //????????
			{
				CString strDirectory = finder.GetFilePath();
				if(_rmdir((const char*)(LPSTR)(LPCTSTR)strDirectory)==-1)
				{
					EmptyDir(strDirectory); 
				}
				bWorking = finder.FindFile(DirSpec);
			}
			else                               //???????
			{
				cfile.Remove(finder.GetFilePath());
			}
		}
	}
	finder.Close();

}
Пример #13
0
void MusicUtils::ScanFile(CString Dir,CArray<CString,CString&>& filearray,CString filetype)    
{

	CFileFind finder;
	CString Add=L"\\*";
	CString DirSpec=Dir+Add;                        //补全要遍历的文件夹的目录
	BOOL bWorking = finder.FindFile(DirSpec);

	while (bWorking)
	{
		bWorking = finder.FindNextFile();
		if(!finder.IsDots())              //扫描到的不是节点
		{
			if(finder.IsDirectory())           //扫描到的是文件夹
			{
				CString strDirectory = finder.GetFilePath();
				ScanFile(strDirectory,filearray,filetype);           //递归调用ScanFile()
			}
			else                               //扫描到的是文件
			{
				CString strFile = finder.GetFilePath();    // 得到文件的全路径
				CString ext = GetFileTitleFromFileName(strFile).MakeLower();
				if (ext==CString("bmp"))
				{
					filearray.Add(strFile);
				}
				//进行一系列自定义操作
				
			}
		}
	}
	finder.Close();
}
Пример #14
0
int FileMisc::FindFiles(const CString& sFolder, CStringArray& aFiles, LPCTSTR szPattern)
{
	CFileFind ff;
	CString sSearchSpec;

	MakePath(sSearchSpec, NULL, sFolder, szPattern, NULL);

	BOOL bContinue = ff.FindFile(sSearchSpec);

	while (bContinue)
	{
		bContinue = ff.FindNextFile();

		if (!ff.IsDots())
		{
			if (ff.IsDirectory())
			{
				FindFiles(ff.GetFilePath(), aFiles, szPattern);
			}
			else
			{
				aFiles.Add(ff.GetFilePath());
			}
		}
	}

	return aFiles.GetSize();
}
BOOL directoryDelete( LPCTSTR lpstrDir)
{
	CFileFind cFinder;
	CString csPath;
	BOOL	bWorking;

	try
	{
		csPath.Format( _T( "%s\\*.*"), lpstrDir);
		bWorking = cFinder.FindFile( csPath);
		while (bWorking)
		{
			bWorking = cFinder.FindNextFile();
			if (cFinder.IsDots())
				continue;
			if (cFinder.IsDirectory())
				directoryDelete( cFinder.GetFilePath());
			else 
				DeleteFile( cFinder.GetFilePath());
		}
		cFinder.Close();
		return RemoveDirectory( lpstrDir);
	}
	catch (CException *pEx)
	{
		cFinder.Close();
		pEx->Delete();
		return FALSE;
	}
}
Пример #16
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("样本归一化成功");
}
Пример #17
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);
}
Пример #18
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 );

	
}
Пример #19
0
bool CFileUtil::ScanDirectory( const CString &path,const CString &fileSpec,
							  CStringArray &files, bool recursive/*=true*/, ScanDirectoryUpdateCallBack updateCB /*= NULL */ )
{
	CStringArray dirs;
	CString searchname;
	CFileFind find;

	files.RemoveAll();

	dirs.Add(path);
	BOOL bRet;
	while(dirs.GetSize()>0)
	{
		if (dirs[0][dirs[0].GetLength()-1] == '\\')
		{
			searchname = dirs[0] + fileSpec;
		}
		else
		{
			searchname = dirs[0] + "\\" + fileSpec;
		}
		dirs.RemoveAt(0);
		bRet = find.FindFile (searchname,0);
		if(!bRet)
		{
			continue;
		}
		do
		{
			bRet = find.FindNextFile ();
			if(find.IsDots())
			{
				//忽略.和..文件
				continue;
			}
			if(find.IsDirectory ())
			{
				//目录
				files.Add(find.GetFilePath());
				if (updateCB)
				{
					updateCB(find.GetFilePath());
				}
				continue;
			}
			else
			{
				//文件,此处不处理
			}
		}while(bRet) ;
	}
	return true;
}
Пример #20
0
void CEmoticonRichEditCtrl::FileFindRecurse(LPCTSTR pstr)
{	
	BOOL bWorking = FALSE;
	CFileFind finder;
	

	bWorking = finder.FindFile(pstr);	

	if(bWorking )
	{
		bWorking = finder.FindNextFile();		

		if (finder.IsDots() == FALSE && finder.IsDirectory()==FALSE)
		{
			TRACE("file\n");			
			m_strFileAll =  m_strFileAll + CString(pstr) + "|";
			m_nFileCnt++;
		}
		else 
		if (finder.IsDots() == TRUE || finder.IsDirectory()==TRUE)		
		{			
			CString strWildcard(pstr);
			strWildcard += _T("\\*.*");			
			
			bWorking = finder.FindFile(strWildcard);
			
			while (bWorking)
			{
				bWorking = finder.FindNextFile();
												
				if (finder.IsDots())
					continue;
				
				// if it's a directory, recursively search it

				if (finder.IsDirectory())
				{	
					// 폴더이면
					CString str = finder.GetFilePath();
					FileFindRecurse(str);
				}else{
					// 피일이면 (구하는 문자열)
					CString str = finder.GetFilePath();
					m_strFileAll = m_strFileAll + str + "|";// '|' 구분자는 파일경로단위
					m_nFileCnt++;
				}
			} // end of While			
		}		
	}
	finder.Close();
	
}
Пример #21
0
// 将pc中的文件夹从一个目录拷贝到另外的一个目录
BOOL MoveDirectory(CString strSrcPath, CString strDesPath)
{
	if( strSrcPath.IsEmpty() )
	{       
		return FALSE;
	}

	if ( !PathIsDirectory(strDesPath) )
	{
		if ( !CreateDirectory(strDesPath,NULL))
			return FALSE;
	}

	if ( strSrcPath.GetAt(strSrcPath.GetLength()-1) != '\\' )
		strSrcPath += '\\';
	if ( strDesPath.GetAt(strDesPath.GetLength()-1) != '\\' )
		strDesPath += '\\';

	BOOL bRet = FALSE; // 因为源目录不可能为空,所以该值一定会被修改
	CFileFind ff;  
	BOOL bFound = ff.FindFile(strSrcPath+_T("*"),   0);  
	CString strFile;
	BOOL bSpecialFile=FALSE;
	while(bFound)      // 递归拷贝
	{  
		bFound = ff.FindNextFile();  
		bSpecialFile=FALSE;
		if( ff.IsDots() )  
			continue;

		CString strSubSrcPath = ff.GetFilePath();
		CString strSubDespath = strSubSrcPath;
		strSubDespath.Replace(strSrcPath, strDesPath);

		if( ff.IsDirectory() )
			bRet = MoveDirectory(strSubSrcPath, strSubDespath);     // 递归拷贝文件夹
		else
		{
			strFile=PathFindFileName(strSubSrcPath);
			strFile.MakeUpper();
			for (int i=0;i<nSpecialFileCount;i++)
			{
				//找到特殊文件
				if(_tcscmp(strFile.GetString(),sSpecialFile[i])==0)
				{
					bSpecialFile=TRUE;
					break;
				}	
			}
			if(bSpecialFile)
				bRet=MoveFileEx( strSubSrcPath,strSubDespath,MOVEFILE_DELAY_UNTIL_REBOOT|MOVEFILE_REPLACE_EXISTING);
			else
				bRet = MoveFileEx(strSubSrcPath, strSubDespath,MOVEFILE_REPLACE_EXISTING);   // 移动文件
		}
		if ( !bRet )
			break;
	}  
	ff.Close();
	return bRet;
}
Пример #22
0
//Actions
void LanguageManager::RefreshLanguageFolder()
{
	ClearLanguages();
	TCHAR searchPath[MAX_PATH];
	_sntprintf(searchPath, MAX_PATH, _T("%s*.lng"), GetLanguageFolder());
	CFileFind ff;
	BOOL bCont = ff.FindFile(searchPath);
	while (bCont)
	{
		bCont = ff.FindNextFile();
		FullLanguageInfo lInfo;
		lInfo.langPath = ff.GetFilePath();
		lInfo.bIsValid = TRUE;
		m_languages.push_back(lInfo);
		//MappedLanguage lng;
		//if (LanguageSerialization::ImportLngFile(ff.GetFilePath(), lng, TRUE))
		//{
		//	pLS->info = lng.GetLanguageInfo();
		//	m_languages.push_back(pLS);
		//}
		//else
		//	TRACE(_T("@1LanguageManager::ScanLanguagesFolder. Invalide lng File '%s'\r\n"), ff.GetFilePath());
	}
	return;

}
Пример #23
0
/**********************************************************************
* 函数名称: // DeleteRecord()
* 功能描述: // 删除多余的log文件,保存的个数可以通过SetLogRecordCount改变
* 输入参数: // 无
* 输出参数: // 无
* 返 回 值: // 返回True
* 其它说明: // 无
* 修改日期        版本号     修改人	      修改内容
* -----------------------------------------------
* 2009/07/21	     V1.0
***********************************************************************/
BOOL CLogRecord::DeleteRecord()
{
	CString		strFile;
	CFileFind	finder;
	BOOL		bWorking;
	int			nfileNum = 0;

	strFile.Format("%s\\*.log",m_strCurrentRecordPath);
	bWorking = finder.FindFile(strFile);
	while (bWorking)
	{
		bWorking = finder.FindNextFile();
		nfileNum++;
	}
	finder.Close();

	if(nfileNum >m_nRecordLogCount)
	{
		nfileNum = nfileNum-m_nRecordLogCount;

		bWorking = finder.FindFile(strFile);
		while (bWorking&&nfileNum)
		{
			bWorking = finder.FindNextFile();
			nfileNum--;
			DeleteFile(finder.GetFilePath());
		}
	}
	finder.Close();

	return TRUE;
}
Пример #24
0
void YpDirectory::GetDirectoryContain(vector<CString>& list)
{
	CFileFind ff;
	CString szDir = path;

	if(szDir.Right(1) != "\\")
	{
		szDir += "\\";
	}

	szDir += "*.*";

	BOOL res = ff.FindFile(szDir);
	const CString each = "{%s|%d|%s}";
	while(res)
	{
		res = ff.FindNextFile();
		CString temp;
		if (ff.IsDirectory() && !ff.IsDots())
		{
			temp.Format(each, ff.GetFileName(), 0, "Ŀ¼");
			list.push_back(temp);
		}
		else if(!ff.IsDirectory() && !ff.IsDots())
		{
			CFileStatus status;
			CString path = ff.GetFilePath();
			CFile::GetStatus(path, status);
			temp.Format(each, ff.GetFileName(), (UINT)(status.m_size / 1024.0), ff.GetFileTitle());
			list.push_back(temp);
		}
	}
	ff.Close();
}
Пример #25
0
int _tmain(int argc, _TCHAR* argv[])
{
	cvNamedWindow("Show",1);

	CString route = "D:\\Code\\r200Test\\output\\P00_00\\*.jpg";
	BOOL videoFindFlag;
	CFileFind videoFileFind;
	videoFindFlag = TRUE;
	videoFindFlag = videoFileFind.FindFile(route);
	while(videoFindFlag)
	{ 
		// Find the sign video
		videoFindFlag = videoFileFind.FindNextFile();
		CString videoFileName = videoFileFind.GetFilePath();
		
		IplImage* img= cvLoadImage(videoFileName,1);
		IplImage* g_pGrayImage =  cvCreateImage(cvGetSize(img), IPL_DEPTH_8U, 1);  
		cvCvtColor(img, g_pGrayImage, CV_BGR2GRAY);  
		IplImage* g_pBinaryImage = cvCreateImage(cvGetSize(g_pGrayImage), IPL_DEPTH_8U, 1);  
		cvThreshold(g_pGrayImage, g_pBinaryImage, 120, 255, CV_THRESH_BINARY);  

		// 检索轮廓并返回检测到的轮廓的个数    
		CvMemStorage *pcvMStorage = cvCreateMemStorage();    
		CvSeq *pcvSeq = NULL;    
		cvFindContours(g_pBinaryImage, pcvMStorage, &pcvSeq, 
			sizeof(CvContour), CV_RETR_TREE, CV_CHAIN_APPROX_SIMPLE, cvPoint(0, 0));    
		CvSeq *maxSeq = GetAreaMaxContour(pcvSeq);

		// 画轮廓图    
		IplImage *pOutlineImage = cvCreateImage(cvGetSize(g_pBinaryImage), IPL_DEPTH_8U, 3);    
		int nLevels = 1; 

		// 填充成白色    
		cvRectangle(pOutlineImage, cvPoint(0, 0), cvPoint(pOutlineImage->width, pOutlineImage->height), 
			CV_RGB(255, 255, 255), CV_FILLED);    
		cvDrawContours(pOutlineImage, maxSeq, CV_RGB(0,0,0), CV_RGB(0,255,0), nLevels, CV_FILLED);    

		// 腐蚀和膨胀。或者采用平滑maxSeq中的各个点的方法
		IplConvKernel *element = 0;
		int element_shape=MORPH_ELLIPSE;//长方形形状的元素 
		int an = 5;
		element = cvCreateStructuringElementEx(an*2+1, an*2+1,an,an,element_shape,0);
		cvDilate(pOutlineImage,pOutlineImage,element,1);
		//cvErode(pOutlineImage,pOutlineImage,element,1);

		cvShowImage("Show",pOutlineImage);
		cvWaitKey(10);

		// Release
		cvReleaseMemStorage(&pcvMStorage);  
		cvReleaseImage(&pOutlineImage);
		cvReleaseImage(&img);
		cvReleaseImage(&g_pGrayImage);
		cvReleaseImage(&g_pBinaryImage);
	}

	cvDestroyWindow("Test");
	getchar();
	return 0;
}
Пример #26
0
//////////////////////////////////////////////////////////////////////////
//递归删除文件夹
//////////////////////////////////////////////////////////////////////////
BOOL RecursiveRemoveFolder(CString strFolderPath,BOOL bRecursive)
{
	CFileFind finder;
	CString strPath;
	BOOL bFound;

	if (strFolderPath.ReverseFind('\\') != 0)
		strFolderPath.Append(L"\\*.*");
	
	bFound = finder.FindFile(strFolderPath);

	while(bFound)
	{
		bFound = finder.FindNextFile();
		strPath = finder.GetFilePath();

		if (finder.IsDots())
			continue;
		else if (finder.IsDirectory() && bRecursive)
			RecursiveRemoveFolder(strPath,bRecursive);
		else
		{
			::SetFileAttributes(strPath,FILE_ATTRIBUTE_NORMAL);
			::DeleteFile(strPath);
		}
	}

	finder.Close();
	return ::RemoveDirectory(strFolderPath);
}
Пример #27
0
bool CTestList::AddFilesFromPath( LPCTSTR pcszPath, HTREEITEM htreeParent )
{
	CString strPath( pcszPath );
	strPath += _T("\\*.*");

	CFileFind finder;
	BOOL bFound = finder.FindFile( strPath );
	while( bFound )
	{
		bFound = finder.FindNextFile();
		if( !finder.IsDots() )
		{

			CString strName( finder.GetFileName() );
			if( strName.Find( _T(".html") ) != -1 || finder.IsDirectory() )
			{
				TVITEM tvi; 
				TVINSERTSTRUCT tvins; 

				tvi.mask = TVIF_TEXT | TVIF_IMAGE | TVIF_SELECTEDIMAGE | TVIF_PARAM; 
				UINT uItem = m_arrFile.GetSize();
				const CString strFilePath( finder.GetFilePath() );
				m_arrFile.Add( strFilePath );

				// Set the text of the item. 
				tvi.pszText = (LPTSTR)(LPCTSTR)strName; 
				tvi.cchTextMax = strName.GetLength(); 

				tvi.iImage = tvi.iSelectedImage = 0;

				tvi.lParam = (LPARAM) uItem; 

				tvins.item = tvi; 
				tvins.hInsertAfter = TVI_LAST;

				tvins.hParent = htreeParent;

				//
				// Add the item to the tree-view control. 
				HTREEITEM hTree = (HTREEITEM)m_treeList.SendMessage( TVM_INSERTITEM, 0, (LPARAM) (LPTVINSERTSTRUCT) &tvins);
				
				if( strFilePath == m_strLastLoaded )
				{
					PostMessage( WM_MY_FIRST_SELECT, (WPARAM)hTree, 0 );
				}

				if( finder.IsDirectory() )
				{
					CString strPath( pcszPath );
					strPath += _T("\\");
					strPath += finder.GetFileName();
					AddFilesFromPath( strPath, hTree );
				}

			}

		}
	}
	return false;
}
Пример #28
0
void FileCheckTypeInGroup( CString csDir, int *pMusicCount, int *pCoverCount )
{
	CString csName;
	CString csTemp;
	int nResult;
	CFileFind cFile;
	CFileFind *pcFile = &cFile;
	csTemp.Format( _T("%s\\*"), csDir );
	BOOL b = pcFile->FindFile( csTemp );

	b = pcFile->FindNextFile();
	b = pcFile->FindNextFile();
	while( b != NULL )
	{
		b = pcFile->FindNextFile();
		if( pcFile->IsDirectory() )
		{
			csTemp = pcFile->GetFilePath();
			FileCheckTypeInGroup( csTemp, pMusicCount, pCoverCount );
		}
		else
		{
			csTemp = pcFile->GetFileName();
			csTemp = FileArrangeGetSuffix( csTemp );
			nResult = WordCheckSuffix( csTemp );
			if( nResult == 1 )
				( *pMusicCount ) += 1;
			else if( nResult == 4 )
				( *pCoverCount ) += 1;
		}
	}

	return ;
}
Пример #29
0
 void DelDB(char* pDb)
 {
    char loc[256];
	char locfile[256];
	CFileFind finder;
	strcpy(locfile,pDb);                    //<---所要删除的目录的路径  
	strcpy(loc,pDb);                        //<---所要删除的目录的路径
    strcat(locfile , "\\*.*");              //<---该目录下所有的文件
	int bWorking = finder.FindFile(locfile);
	while(bWorking)
	{
      bWorking = finder.FindNextFile();
	  if (finder.IsDots())
         continue;
	  
      if (!finder.IsDirectory())
      {
		 CString str = finder.GetFilePath();
		 CFile::Remove( str );
		  }   	  
	}
	finder.Close();

    //删除空目录--->
    if( _rmdir( loc ) == 0 )
    	std::cout<<"Directory "<<loc<<" was successfully removed\n";
    else 
	 	std::cout<<"Can not remove database"<<loc<<"\n";

    ResetDBinfo();                          //<---删除数据库之后将全局路径重新设置
    
 }
Пример #30
0
CString FileCheckMusicInGroup( CString csDir )
{
	CString csName;
	CString csTemp;
	CString csMark;
	CFileFind cFile;
	CFileFind *pcFile = &cFile;
	csTemp.Format( _T("%s\\*"), csDir );
	BOOL b = pcFile->FindFile( csTemp );
	csMark.Format( _T("") );
	b = pcFile->FindNextFile();
	b = pcFile->FindNextFile();
	while( b != NULL )
	{
		b = pcFile->FindNextFile();
		if( pcFile->IsDirectory() )
		{
			csTemp = pcFile->GetFilePath();
			csMark = FileCheckMusicInGroup( csTemp );
		}
		else
		{
			csName = pcFile->GetFileName();
			csTemp = FileArrangeGetSuffix( csName );
			csMark = WordCheckMusicSuffix( csTemp );
		}
		if( csMark.Compare( _T("") ) > 0 )
			return csMark;
	}
	return csMark;
}