Example #1
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;
}
Example #2
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();
}
Example #3
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());
		}
	}
}
Example #4
0
BOOL CDirTreeCtrl::FindSubDir( LPCTSTR strPath)
{
	//
	// Are there subDirs ?
	//
	CFileFind find;
	CString   strTemp = strPath;
	BOOL      bFind;

	if ( strTemp[strTemp.GetLength()-1] == '\\' )
		strTemp += _T("*.*");
	else
		strTemp += _T("\\*.*");
		
	bFind = find.FindFile( strTemp );
	
	
	while ( bFind )
	{
		bFind = find.FindNextFile();

		if ( find.IsDirectory() && !find.IsDots() )
		{
			return TRUE;
		}
		if ( !find.IsDirectory() && m_bFiles && !find.IsHidden() )
			return TRUE;
		
	}

	return FALSE;

}
Example #5
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());
}
Example #6
0
BOOL CDirTreeCtrl::AddSubDirAsItem1(HTREEITEM hParent)
{
	CString strPath,strFileName;
	HTREEITEM hChild;
	//---------------------去除该父项下所有的子项------------   // 因为有dummy项,并且有时子目录再次打开,或子目录会刷新等,因此必须去除。
	while ( ItemHasChildren(hParent))  {
		hChild = GetChildItem(hParent);
		DeleteItem( hChild );
	}    //-----------------------装入该父项下所有子项--------------  
	strPath = GetFullPath(hParent);

	CString strSearchCmd = strPath;
	if( strSearchCmd.Right( 1 ) != _T( "\\" ))
		strSearchCmd += _T( "\\" );

	strSearchCmd += _T( "*.*" );
	CFileFind find;
	BOOL bContinue = find.FindFile( strSearchCmd );
	while ( bContinue )  {
		bContinue = find.FindNextFile();
		strFileName = find.GetFileName();

		 if(!find.IsHidden() && ! find.IsDots() && find.IsDirectory() )
		 {
			 hChild = AddItem( hParent, strFileName );
		 }

		if ( !find.IsHidden() && ! find.IsDots() && !find.IsDirectory() )   {
			InsertItem( strFileName, 0, 0, hParent );
		}
    }

    return TRUE; 
}
Example #7
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 );

	
}
Example #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();
	
}
Example #9
0
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));
		}
	}
}
Example #10
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);
			}
		}
	}
}
Example #11
0
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;
}
Example #12
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;
}
Example #13
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();                          //<---删除数据库之后将全局路径重新设置
    
 }
Example #14
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();
}
Example #15
0
void KModelEditorTagExport::OnCbnSelchangeCombo2()
{
	// TODO: Add your control notification handler code here
	CFileFind Find;
	TCHAR strFind[MAX_PATH];
	m_ListBox_Target.ResetContent();
	int nCurSel = m_comboTarget.GetCurSel();
	KG_PROCESS_ERROR(nCurSel != CB_ERR);
	m_comboTarget.GetLBText(nCurSel, m_strTarget);

	sprintf_s(strFind,"%s%s\\动作\\*.ani",m_strPath,m_strTarget);
	BOOL bReturn = Find.FindFile(strFind);
	while (bReturn)
	{
		bReturn = Find.FindNextFile();
		if (!Find.IsDirectory())
		{
			if (Find.GetFileName() != "." && Find.GetFileName() != ".." &&Find.GetFileName().MakeLower() != ".svn")
			{
				char strName[MAX_PATH];
				CString strFileName = Find.GetFileName();
				_splitpath(strFileName, NULL, NULL, strName, NULL);
				m_ListBox_Target.AddString(strName);			
			}
		}
	}
Exit0:
	;
}
Example #16
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();
}
Example #17
0
	// 删除文件夹下指定后缀的文件
	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);
			}
		}
	}
Example #18
0
void GenFileList( CString folder, vector<SFInfo> &list )
{
	folder.TrimRight('\\');
	folder += '\\';

	CFileFind finder;
	BOOL bWork = finder.FindFile(folder+"*.*");
	vector<CString> namelist;
	while(bWork)
	{
		bWork = finder.FindNextFile(); // bWork is zero if the file found is the last one
		if (finder.IsDirectory()) continue;
		CString fn = finder.GetFileName();
		if (fn[0] == '!') continue; // 用一个符号来标识那些不想用来训练的图片
		CString name = ::FindName(fn);

		vector<CString>::iterator iter = namelist.begin();
		int cnt = 0;
		for (; iter != namelist.end(); iter++)
			if (name == *iter) break;
			else cnt++;
		if (cnt == namelist.size()) namelist.push_back(name);
		list.push_back(SFInfo(cnt, fn));
	}
}
Example #19
0
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();
}
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;
	}
}
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;
}
Example #22
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 ;
}
Example #23
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();
}
Example #24
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;
}
Example #25
0
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 );
}
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();
}
Example #27
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;
}
Example #28
0
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();
	
}
Example #29
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;
}
Example #30
0
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());
}