コード例 #1
0
ファイル: File.cpp プロジェクト: jhc888007/MagicMusicManage
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;
}
コード例 #2
0
ファイル: Inform.cpp プロジェクト: wyrover/Windows-Inform7
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());
}
コード例 #3
0
ファイル: File.cpp プロジェクト: jhc888007/MagicMusicManage
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 ;
}
コード例 #4
0
ファイル: LogRecord.cpp プロジェクト: virqin/brew_code
/**********************************************************************
* 函数名称: // 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;
}
コード例 #5
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;
}
コード例 #6
0
ファイル: FileName.cpp プロジェクト: Robertysc/ecos
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();
}
コード例 #7
0
void CTaiKlineDlgHistorySelect::GetFileNameArray(CStringArray &sArry)
{
	CString sPath = "data\\historysh\\";
	CFileFind finder;
	int n = 0;
	BOOL bWorking = finder.FindFile(sPath+"*.hst");
	while(bWorking)
	{
	  bWorking = finder.FindNextFile();
	  CString filename = finder.GetFileTitle();
	  int nSize = sArry.GetSize ();
	  for(int j=0;j<nSize;j++)
	  {
		  if(filename <sArry[j])
		  {
			  sArry.InsertAt (j,filename);
			  break;
		  }
		  if(j==nSize-1)
			sArry.Add (filename);
	  }
	  if(nSize == 0)
			sArry.Add (filename);

	  n++;
	}
	sPath = "data\\historysz\\";
	n = 0;
	bWorking = finder.FindFile(sPath+"*.hst");
	while(bWorking)
	{
	  bWorking = finder.FindNextFile();
	  CString filename = finder.GetFileTitle();
	  int nSize = sArry.GetSize ();
	  BOOL bf;
	  bf=false;
	  for(int j=0;j<nSize;j++)
	  {
		  if(filename ==sArry[j])
		  {
			  bf=true;
			  
			  break;
			  
		  }
		  else
		  {
			  bf=false;
			  continue;
		  }
		  if(j==nSize-1)
			sArry.Add (filename);
	  }
	  if((nSize == 0)||(!bf))
			sArry.Add (filename);
	  n++;
	}
}
コード例 #8
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();
	
}
コード例 #9
0
ファイル: PatchDlg.cpp プロジェクト: isnb/AutoUpdate
// 将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;
}
コード例 #10
0
int KGObjectPropertyEditDlg::GetRootPoint(CString szPath)
{
	int nResult  = false;
	int nRetCode = false;

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

	KG_PROCESS_ERROR(szPath != "");

	int temp = 0;
	while (bContinue)
	{
		bContinue = file.FindNextFile();
		if (file.IsDirectory() && !file.IsDots())
		{
			if (temp == 0)
			{
				m_treeRoot = m_treeObjectView.InsertItem(file.GetFileName());
				temp = 1;
			}
			else
			{
				m_treeObjectView.InsertItem(file.GetFileName());
			}
		}
	}

	nResult = true;
Exit0:
	file.Close();

	return nResult;
}
コード例 #11
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;

}
コード例 #12
0
ファイル: DlgArmLogICImage.cpp プロジェクト: iqk168/3111
void CDlgArmLogICImage::DeleteImageFolder(CString csFolderName)
{
	CString csFilePath = _T("");
	csFilePath = m.FilePath.ArmLogICImagePath + csFolderName + "\\";

	CFileFind find;	
	BOOL bResult = find.FindFile( csFilePath + _ArmLogICImage2 );	
	CString file = _T("");
	m_Files.RemoveAll();
	long lFileSize = 0.0;
	while(bResult)
	{
		bResult = find.FindNextFile();
		file = find.GetFileName();	// Get File Name..
		if(file.Find( _ArmLogICImage, 0)>-1)
		{
			// show file data
			CString csDeleteFilePath = _T("");
			csDeleteFilePath = m.FilePath.ArmLogICImagePath + csFolderName + "\\" + file;
			
			::DeleteFile( csDeleteFilePath );
		}
	}

	//
	CString csDeleteDbFilePath = _T("");
	csDeleteDbFilePath = m.FilePath.ArmLogICImagePath + csFolderName + "\\" + _ArmLogICDb;
	::DeleteFile( csDeleteDbFilePath );

	//
	RemoveDirectory( m.FilePath.ArmLogICImagePath + csFolderName );
}
コード例 #13
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;
}
コード例 #14
0
static void InitLanguages(const CString& rstrLangDir, bool bReInit = false)
{
	static BOOL _bInitialized = FALSE;
	if (_bInitialized && !bReInit)
		return;
	_bInitialized = TRUE;

	CFileFind ff;
	bool bEnd = !ff.FindFile(rstrLangDir + _T("*.dll"), 0);
	while (!bEnd)
	{
		bEnd = !ff.FindNextFile();
		if (ff.IsDirectory())
			continue;
		TCHAR szLandDLLFileName[MAX_PATH];
		_tsplitpath(ff.GetFileName(), NULL, NULL, szLandDLLFileName, NULL);

		SLanguage* pLangs = _aLanguages;
		if (pLangs){
			while (pLangs->lid){
				if (_tcsicmp(pLangs->pszISOLocale, szLandDLLFileName) == 0){
					pLangs->bSupported = TRUE;
					break;
				}
				pLangs++;
			}
		}
	}
	ff.Close();
}
コード例 #15
0
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();
}
コード例 #16
0
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;
	}
}
コード例 #17
0
ファイル: FileSystem.cpp プロジェクト: ypcmos/PhantomServer
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();
}
コード例 #18
0
ファイル: TestPage.cpp プロジェクト: jltong/GraduateWorks
void CTestPage::freshSphLib()
{
	DataBase db;
	BOOL bTraining = FALSE;
	db.ResetTable(_T("SpeechLib"),bTraining);

	//CStringArray* idArray = db.GetAllUserInfo(_T("UserId"));

	CString SpeechDir = _T("F:\\SpeechDirectory");
	CString UserId,WavName,SphPath;
	CFileFind finder;
	
	UserId = _T("Test");
	SphPath = SpeechDir + _T("\\") + UserId + _T("\\") + _T("*.wav");
	BOOL res = finder.FindFile(SphPath);
	while(res){
		res = finder.FindNextFile();
		if(finder.IsDots()||finder.IsDirectory())  
			continue;
		WavName = finder.GetFileName();
		db.InsertSpeechLib(UserId,WavName);		
	}
	
	finder.Close();
	
}
コード例 #19
0
ファイル: FileMgr.cpp プロジェクト: tantaishan/MyEcho
BOOL FileMgr::DeleteDirectory(LPCTSTR Directory)
{
	CFileFind tempFind;
	TCHAR sTempFileFind[MAX_PATH] = { 0 };
	_stprintf_s(sTempFileFind,MAX_PATH, _T("%s//*.*"), Directory);
	BOOL IsFinded = tempFind.FindFile(sTempFileFind);
	while (IsFinded)
	{
		IsFinded = tempFind.FindNextFile();
		if (!tempFind.IsDots())
		{
			TCHAR sFoundFileName[MAX_PATH] = { 0 };
			_tcscpy_s(sFoundFileName, MAX_PATH, tempFind.GetFileName().GetBuffer(200));
			if (tempFind.IsDirectory())
			{
				TCHAR sTempDir[MAX_PATH] = { 0 };
				_stprintf_s(sTempDir, MAX_PATH, _T("%s//%s"), Directory, sFoundFileName);
				DeleteDirectory(sTempDir);
			}
			else
			{
				TCHAR sTempFileName[MAX_PATH] = { 0 };
				_stprintf_s(sTempFileName, MAX_PATH, _T("%s//%s"), Directory, sFoundFileName);
				DeleteFile(sTempFileName);
			}
		}
	}
	tempFind.Close();
	if (!RemoveDirectory(Directory))
	{
		return FALSE;
	}
	return TRUE;
}
コード例 #20
0
ファイル: FileUtils.cpp プロジェクト: yanglianxiang/intern
BOOL FileUtils::rmDir(string dirName)
{
	char sTempFileFind[MAX_PATH] = "";
	sprintf_s(sTempFileFind, "%s\\*.*", dirName.c_str());
	
	CFileFind tempFind;
	BOOL isFinded = tempFind.FindFile(sTempFileFind);
	while (isFinded) {
		isFinded = tempFind.FindNextFile();
		/*
		 * 跳过 每个文件夹下面都有的两个特殊子文件夹:
		 *	(1) .  表示本文件夹自己
		 *	(2) .. 表示本文件夹的父文件夹
		 */
		if (!tempFind.IsDots()) {
			char tempFileOrDir[MAX_PATH] = "";
			sprintf_s(tempFileOrDir, "%s\\%s", dirName.c_str(), tempFind.GetFileName().GetBuffer(MAX_PATH));

			if (tempFind.IsReadOnly()) ::SetFileAttributes(tempFileOrDir, FILE_ATTRIBUTE_NORMAL);
			
			if (tempFind.IsDirectory()) rmDir(tempFileOrDir);
			else ::DeleteFile(tempFileOrDir);
		}
	}
	tempFind.Close();

	return ::RemoveDirectory(dirName.c_str());
}
コード例 #21
0
void COptionsGeneral::FillLanguages()
{
	CString csFile = CGetSetOptions::GetPath(PATH_LANGUAGE);
	csFile += "*.xml";

	CString csLanguage = CGetSetOptions::GetLanguageFile();

	CFileFind find;
	BOOL bCont = find.FindFile(csFile);
	int nEnglishIndex = NO_MATCH;

	while(bCont)
	{
		bCont = find.FindNextFile();
		int nIndex = m_cbLanguage.AddString(find.GetFileTitle());

		if(find.GetFileTitle() == csLanguage)
		{
			nEnglishIndex = -1;
			m_cbLanguage.SetCurSel(nIndex);
		}
		else if(find.GetFileTitle() == _T("English"))
		{
			if(nEnglishIndex == NO_MATCH)
				nEnglishIndex = nIndex;
		}
	}

	if(nEnglishIndex >= 0)
	{
		m_cbLanguage.SetCurSel(nEnglishIndex);
	}
}
コード例 #22
0
ファイル: FileMisc.cpp プロジェクト: noindom99/repositorium
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();
}
コード例 #23
0
ファイル: DlgArmLogICImage.cpp プロジェクト: iqk168/3111
void CDlgArmLogICImage::UpdataFolderStatus()
{
	// Get the folder name
	m_Folder.RemoveAll();

	CString csFilePath = _T("");
	csFilePath = m.FilePath.ArmLogICImagePath;
	CFileFind finder;											//建立搜尋用的CFileFind物件
	BOOL bResult = finder.FindFile( csFilePath  + "*.*" );		//尋找第一個檔案
	while(bResult)
	{
		bResult = finder.FindNextFile();						//尋找下一個檔案
		if(!finder.IsDots() && finder.IsDirectory())
		{
			CString csFileDirectory = _T("");
			csFileDirectory.Format("%s", finder.GetFileTitle() );
			
			m_Folder.Add( csFileDirectory );
		}
	}
	
	m_listFolderStatus.ResetContent();
	int iSize = m_Folder.GetSize();
	for(int i=0;i<iSize;i++)
	{
		CString csFolderName = _T("");
		csFolderName = m_Folder.GetAt(i);
		m_listFolderStatus.AddString( csFolderName );
	}
	CString csFolderCounter = _T("");
	csFolderCounter.Format("Folder Counter: %d", iSize );
	m_wndlistFolderCounter.SetWindowText( csFolderCounter );
}
コード例 #24
0
ファイル: FuncFile.cpp プロジェクト: 0fly0/BatchModify
	// 删除文件夹下指定后缀的文件
	void DeleteDirectory(CString strPath,CString strSuffix)
	{
		CString strTemp=strPath;
		CString strFilePath=strPath;
		CFileFind finder;
		BOOL bWorking;
		bWorking=finder.FindFile(strPath+_T("\\*")+strSuffix);
		while(bWorking)
		{
			bWorking = finder.FindNextFile();
			//如果是“.”则不处理
			if (finder.IsDots())
			{
				continue;
			}
			//如果是目录,继续扫描此目录
			else if (finder.IsDirectory())
			{
				strPath = finder.GetFileName();
				strTemp = strTemp+_T("\\")+strPath;
				DeleteDirectory(strTemp,strSuffix);
			}
			//文件
			else
			{
				strPath = finder.GetFileName();
				strFilePath=strFilePath+_T("\\")+strPath;
				DeleteFile(strFilePath);
				CString strCut = _T("\\")+strPath;
				strFilePath.Replace(strCut,_T(""));
				//strFilePath.TrimLeft(strCut);
			}
		}
	}
コード例 #25
0
ファイル: CTableMapLoader.cpp プロジェクト: ohzooboy/oh
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);
			}
		}
	}
}
コード例 #26
0
ファイル: Display.cpp プロジェクト: V756568/MiniSQL
 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();                          //<---删除数据库之后将全局路径重新设置
    
 }
コード例 #27
0
ファイル: FileHelpers.cpp プロジェクト: ror13/diplom
static void staticPathList(std::list<CString>& paths, std::set<CString>& folders, const CString& startDir, const CString& folder, BOOL recursive)
{
	CString strDirectory = PathJoin(startDir, folder);

	CFileFind finder;	
	BOOL bWorking = finder.FindFile(strDirectory + _T("\\*.*"));
	while (bWorking)
	{
		bWorking = finder.FindNextFile();

		CString filename = finder.GetFileName();

		if (filename == "." || filename == "..")
			continue;

		if (finder.IsDirectory())
		{
			if (recursive)
			{
				staticPathList(paths, folders, startDir, PathJoin(folder, filename), recursive);
			}
			folders.insert(PathJoin(folder, filename));
		}
		else
		{
			paths.push_back(PathJoin(folder, filename));
		}
	}
}
コード例 #28
0
ファイル: Display.cpp プロジェクト: V756568/MiniSQL
void ShowDB()
{

	CFileFind finder;
	int iRowN = 0;
    int iNameLen = 0,iTemp = 0;
	std::cout<<"These are the databases !\n";
    int bWorking = finder.FindFile("..\\Data\\*.*");
	std::cout<<"~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~"<<'\n';//<---计32个字符
	std::cout<<"| Database                     |"<<'\n';
	std::cout<<"~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~"<<'\n';//<---计32个字符
	while(bWorking)
	{
		
      bWorking = finder.FindNextFile();
	  if (finder.IsDots())
         continue;
	  
      if (finder.IsDirectory())
      {
		 iRowN++;
         CString str = finder.GetFileTitle();
		 iNameLen = str.GetLength(); 
		 std::cout <<"| "<< (LPCTSTR) str;
		 for(iTemp = 29 - iNameLen;iTemp != 0;iTemp--)
			 std::cout<<' ';
		std::cout <<"|"<<'\n';
	  }   	  
	}
   	std::cout<<"~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~"<<'\n';//<---计32个字符
	std::cout<<"There are" <<iRowN<<" rows in the database!";
	finder.Close();
}
コード例 #29
0
ファイル: Lang.cpp プロジェクト: Lamobo/Lamobo-D1
UINT CLang::ScanLang(CString dirPath)
{
	CString langName;
	CString fileName;
	BOOL bFound;
	UINT pos;
	CFileFind cFF;
	
	bFound = cFF.FindFile(dirPath+"\\*.txt");
	if(bFound)
	{
		do
		{
			bFound = cFF.FindNextFile();//查下一个
			
			fileName = cFF.GetFileTitle();//
			if(fileName != _T("中文") && fileName != _T("English"))//不等时
			{
				pos = fileName.Find('.');//
				langName = fileName.Left(pos);//
				m_langName[m_langCount] = fileName;//
				m_langCount++;
			}
			
		}
		while(bFound);//
	}
	else
	{
		return 0;
	}

	return m_langCount-2;//
}
コード例 #30
0
bool DeleteDirectory(const char *DirName)//如删除DeleteDirectory("c:\\aaa") 
{
    CFileFind tempFind;
    char tempFileFind[MAX_PATH];
    sprintf(tempFileFind,"%s\\*.*",DirName);
    BOOL IsFinded=(BOOL)tempFind.FindFile(tempFileFind);
    while(IsFinded)
    {
        IsFinded=(BOOL)tempFind.FindNextFile();
        if(!tempFind.IsDots())
        {
            char foundFileName[MAX_PATH];
            strcpy(foundFileName,tempFind.GetFileName().GetBuffer(MAX_PATH));
            if(tempFind.IsDirectory())
            {
                char tempDir[MAX_PATH];
                sprintf(tempDir,"%s\\%s",DirName,foundFileName);
                DeleteDirectory(tempDir);
            }
            else
            {
                char tempFileName[MAX_PATH];
                sprintf(tempFileName,"%s\\%s",DirName,foundFileName);
                DeleteFile(tempFileName);
            }
        }
    }
    tempFind.Close();
    if(!RemoveDirectory(DirName))
    {
        //MessageBox(0,"删除目录失败!","警告信息",MB_OK);//比如没有找到文件夹,删除失败,可把此句删除
        return FALSE;
    }
    return TRUE;
}