Esempio n. 1
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; 
}
Esempio n. 2
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;

}
Esempio n. 3
0
BOOL CFileAndFolder::HasGotSubEntries(const CString& sDirectory)
{
  ASSERT(sDirectory.GetLength());
  CFileFind find;
  CString sFile;
  if (sDirectory.GetAt(sDirectory.GetLength()-1) == _T('\\'))
    sFile = sDirectory + _T("*.*");
  else
    sFile = sDirectory + _T("\\*.*");
  BOOL bFind = find.FindFile(sFile);  
  while (bFind)
  {
    bFind = find.FindNextFile();
    if (find.IsDirectory() && !find.IsDots())
      return TRUE;
    else if (!find.IsDirectory() && !find.IsHidden() && m_bShowFiles)
      return TRUE;
  }

  return FALSE;
}
Esempio n. 4
0
BOOL CPackagePage::OnSetActive() 
{
	SetWizardButtons( PSWIZB_BACK | PSWIZB_NEXT );

	if ( ! theApp.m_sCommandLineSourceFile.IsEmpty() )
	{
		CStringList oDirs;
		oDirs.AddTail( theApp.m_sCommandLineSourceFile );
		theApp.m_sCommandLineSourceFile.Empty();

		while ( ! oDirs.IsEmpty() )
		{
			CString strFolder = oDirs.RemoveHead() + _T("\\");
			CFileFind finder;
			BOOL bWorking = finder.FindFile( strFolder + _T("*.*") );
			while ( bWorking )
			{
				bWorking = finder.FindNextFile();
				if ( ! finder.IsDots() && ! finder.IsHidden() )
				{
					CString sFilename = strFolder + finder.GetFileName();
					if ( finder.IsDirectory() )
						oDirs.AddTail( sFilename );
					else
						AddFile( sFilename );
				}
			}
		}

		if ( m_wndList.GetItemCount() > 0 )
			Next();
	}

	m_wndRemove.EnableWindow( m_wndList.GetSelectedCount() > 0 );

	UpdateData( FALSE );

	return CWizardPage::OnSetActive();
}
void CFileView::Refresh(char *dir)
{
	// listview을 모두 지운다.
	CListCtrl& list = GetListCtrl(); // !!!!!!!!!!!
	list.DeleteAllItems();
	SetCurrentDirectory( dir );

	CFileFind f; BOOL b = f.FindFile("*.*");

	while ( b )
	{
		b = f.FindNextFile();

		if ( ! f.IsDirectory() && ! f.IsHidden() )
		{
			list.InsertItem(0, f.GetFileName(), 0);
			
			CString msg;
			msg.Format( "%d KB", (f.GetLength() / 1024) + 1 );
			list.SetItemText(0, 1, msg );
		}
	}
}
//------------------------------------------------
// 파일의 리스트 및 각 파일에 대한 자세한 정보를 
// 함께 저장하게 됨
// data.h파일에 해당 구조체를 선언한다.
//--------------------------------------------------
void CMyExplorerDoc::SelectTreeViewFolder(CString strFullName)
{

	LIST_VIEW*	pListView;
	CFileFind	ff;

	// 사용자가 폴더를 선택할 때마다 파일 리스트를
	// 새로 업데이트 해야 함
	// 따라서 기존 정보를 모두 삭제한다.
	if (m_pFileList != NULL)
		RemoveAllFileList();

	m_pFileList = new CObList;

	SetCurrentPath(strFullName);
	strFullName += "*.*";

	if (ff.FindFile(strFullName) == TRUE)
	{
		BOOL	bFlag = TRUE;
		while(bFlag == TRUE)
		{
			bFlag = ff.FindNextFile();

			// 디렉토리 , 도트파일이면 다시 찾음 
			if (ff.IsDirectory() || ff.IsDots())
				continue;
			
			// 파일 정보를 알아내서LIST_VIEW 구조체에 
			// 저장한 후 
			// 그것을 모두 m_pFileList에 저장한다.
			pListView = new LIST_VIEW;
			InitListViewStruct(pListView);

			pListView->strName = ff.GetFileName();
			pListView->strPath = ff.GetFilePath();

			CString		strName = pListView->strName;
			CString		strExt = ff.GetFileTitle();

			int			nNum = strName.GetLength() - strExt.GetLength();

			if (nNum == 0)
				strExt = "";
			else
				strExt = strName.Right(nNum - 1);
			pListView->strKind = strExt + " 파일";
			pListView->dwFileSize = ff.GetLength();

			CTime	time;
			if (ff.GetCreationTime(time) == TRUE)
				pListView->tCreateTime = time;
			if (ff.GetLastAccessTime(time) == TRUE)
				pListView->tLastAccessTime = time;
			if (ff.GetLastWriteTime(time) == TRUE)
				pListView->tLastWriteTime = time;
			if (ff.IsHidden() == TRUE)
				pListView->bIsHidden = TRUE;
			if (ff.IsReadOnly() == TRUE)
				pListView->bIsReadOnly = TRUE;
			if (ff.IsArchived() == TRUE)
				pListView->bIsArchived = TRUE;
			if (ff.IsSystem() == TRUE)
				pListView->bIsSystem = TRUE;

			m_pFileList->AddTail((CObject*)pListView);
		}
	}
	ff.Close();

	//------------------------------
	m_pExpListView->SetFileList();
	//-------------------------------------
}
Esempio n. 7
0
void CACEdit::ReadDirectory(CString m_Dir)
{
	CFileFind FoundFiles;
	TCHAR ch;
	CWaitCursor hg;

	// Wenn mittem im Pfad,
	// vorheriges Verzeichnis einlesen.
	if (m_Dir.Right(1) != _T('\\'))
	{
		_tsplitpath(m_Dir, m_szDrive, m_szDir, m_szFname, m_szExt);
		m_Dir.Format(_T("%s%s"),m_szDrive, m_szDir);
	}

	//ist hübscher
	ch = (TCHAR)towupper(m_Dir.GetAt(0));
	m_Dir.SetAt(0,ch);

	CString m_Name,m_File,m_Dir1 = m_Dir;
	if (m_Dir.Right(1) != _T('\\'))
		m_Dir += _T("\\");

	if(m_LastDirectory.CompareNoCase(m_Dir) == 0 && m_Liste.m_SearchList.GetSize())
		return;

	m_LastDirectory = m_Dir;
	m_Dir += _T("*.*");

	BOOL bContinue = FoundFiles.FindFile(m_Dir);
	if(bContinue)
		RemoveSearchAll();

	while (bContinue == TRUE)
	{
		bContinue = FoundFiles.FindNextFile();
		m_File = FoundFiles.GetFileName();

		if(FoundFiles.IsHidden() || FoundFiles.IsSystem())
			continue;
		if(FoundFiles.IsDirectory())
		{
			if(m_iMode & _MODE_ONLY_FILES)
				continue;
			if(FoundFiles.IsDots())
				continue;

			if (m_File.Right(1) != _T('\\'))
				m_File += _T("\\");
		}

		if(!FoundFiles.IsDirectory())
			if(m_iMode & _MODE_ONLY_DIRS)
				continue;

		if(m_iMode & _MODE_FS_START_DIR_)
		{
			m_Name = m_File;
		}
		else
		{
			m_Name = m_Dir1;
			if (m_Name.Right(1) != _T('\\'))
				m_Name += _T("\\");

			m_Name += m_File;
		}

		AddSearchString(m_Name);
	}
	FoundFiles.Close();
	return;

}
Esempio n. 8
0
void CFileAndFolder::DisplayPath(const CString& sPath, 
								 HTREEITEM hParent, BOOL bUseSetRedraw)
{
  CWaitCursor c;

  //Speed up the job by turning off redraw
//  if (bUseSetRedraw)
//    SetRedraw(FALSE);

  //Remove all the items currently under hParent
  HTREEITEM hChild = m_Tree.GetChildItem(hParent);
  while (hChild)
  {
    m_Tree.DeleteItem(hChild);
    hChild = m_Tree.GetChildItem(hParent);
  }

  //Find all the directories and files underneath sPath
  CSortedArray<CString, CString&> DirectoryPaths;
  CSortedArray<CString, CString&> FilePaths;
  CFileFind find;
  CString sFile;
  if (sPath.GetAt(sPath.GetLength()-1) == _T('\\'))
    sFile = sPath + _T("*.*");
  else
    sFile = sPath + _T("\\*.*");
  
  BOOL bFind = find.FindFile(sFile);  
  while (bFind)
  {
    bFind = find.FindNextFile();
    if (find.IsDirectory())
    {
      if (!find.IsDots())
      {
        CString sPath = find.GetFilePath();
        DirectoryPaths.Add(sPath);
      }
    }
    else 
    {
      if (!find.IsHidden() && m_bShowFiles)
      {
        CString sPath = find.GetFilePath();
        FilePaths.Add(sPath);
      }  
    }
  }

  //Now sort the 2 arrays prior to added to the tree control
  DirectoryPaths.SetCompareFunction(CompareByFilenameNoCase);
  FilePaths.SetCompareFunction(CompareByFilenameNoCase);
  DirectoryPaths.Sort();
  FilePaths.Sort();

  //Now add all the directories to the tree control
  for (int i=0; i<DirectoryPaths.GetSize(); i++)
  {
    CString& sPath = DirectoryPaths.ElementAt(i);
    TCHAR path_buffer[_MAX_PATH];
    TCHAR fname[_MAX_FNAME];
    TCHAR ext[_MAX_EXT];
    _tsplitpath(sPath, NULL, NULL, fname, ext);
    _tmakepath(path_buffer, NULL, NULL, fname, ext);
    InsertFileItem(path_buffer, sPath, hParent);
  }

  //And the files to the tree control (if required)
  for (i=0; i<FilePaths.GetSize(); i++)
  {
    CString& sPath = FilePaths.ElementAt(i);
    TCHAR path_buffer[_MAX_PATH];
    TCHAR fname[_MAX_FNAME];
    TCHAR ext[_MAX_EXT];
    _tsplitpath(sPath, NULL, NULL, fname, ext);
    _tmakepath(path_buffer, NULL, NULL, fname, ext);
    InsertFileItem(path_buffer, sPath, hParent);
  }

  //Turn back on the redraw flag
//  if (bUseSetRedraw)
//    SetRedraw(TRUE);
}
Esempio n. 9
0
void CFavMenu::AddToIEFav(HMENU fmenu, CString favpath, UINT &id)
{
	static short menu_level = 0;
	menu_level++;
	favmenus.Add(fmenu);

	CStringArray favs;

	DWORD count = 0;
	LPSTR pdata = NULL;
	BYTE* data = NULL;

	favs.SetSize(count, 64);

	CFileFind finder;
	BOOL found = finder.FindFile(favpath + "\\*.*");
	while (found)
	{
		found = finder.FindNextFile();
		if (!finder.IsDots() && !finder.IsHidden())
		{
			CString title = finder.GetFileTitle();
			BOOL bdir = finder.IsDirectory();

			CString item;
			if (finder.IsDirectory())
			{
				//取得有"."的資料夾名稱 by NomedEmag 07/06/08
				title = finder.GetFileName();
				//
				item = 'd' + title;
			}
			else
			{
				item = 'w' + title;
				item += '\t';
				CString ads;
				DWORD retl = GetPrivateProfileString("InternetShortcut", "URL", "",
													 ads.GetBuffer(2048), 2048 , finder.GetFilePath());
				ads.ReleaseBuffer();
				item += ads;
			}

			favs.Add(item);
		}
	}
	finder.Close();

	if (data)
		delete []data;

	//利用特殊技巧 qsort,這是依賴 MFC 的內部實做方式,將來可能有變
	if (AppConfig.autosort_favorite)
		qsort(favs.GetData(), favs.GetSize(), sizeof(CString), FavItemCompare);

//	long menuh=GetSystemMetrics(SM_CYMENU)*4+64;

//	UINT id = ID_FIRST_WEB_FAVORITE;
	int menu_height = 0;
	for (int i = 0; i < favs.GetSize(); ++i)
	{
		if (!favs[i].IsEmpty())
		{
			web_fav.Add(favs[i]);
			if ('d' == favs[i][0])
			{
				HMENU submenu = CreatePopupMenu();
				AppendMenu(fmenu, MF_OWNERDRAW | MF_POPUP, (UINT)submenu, LPCTSTR(id), menu_height);
				++id;
				AddToIEFav(submenu, (favpath + '\\' + (LPCTSTR(favs[i]) + 1)), id);
			}
			else
			{
				AppendMenu(fmenu, MF_OWNERDRAW, id, LPCTSTR(id), menu_height);
				++id;
			}
		}
	}
	web_fav.Add(sep);
	++id;
	::AppendMenu(fmenu, MF_SEPARATOR, 0, 0);

	web_fav.Add(add_to_fav);
	AppendMenu(fmenu, MF_OWNERDRAW, id/*ID_ADDTOFAVORITE*/, LPCTSTR(id), menu_height);	id++;

	web_fav.Add(open_all);
	AppendMenu(fmenu, MF_OWNERDRAW, id/*ID_FAVORITE_OPENALL*/, LPCTSTR(id), menu_height);	id++;

	web_fav.Add(org_fav);
	AppendMenu(fmenu, MF_OWNERDRAW, id/*ID_FAVORITE_EDIT*/, LPCTSTR(id), menu_height);	id++;

	menu_level--;

	if (!menu_level)
	{
		web_fav.Add(add_to_home);
		AppendMenu(fmenu, MF_OWNERDRAW, ID_ADDTOHOME, LPCTSTR(id), menu_height);
		++id;
	}
	else
	{
		//  AfxGetEmptyString();
		web_fav.Add(_T(""));	// afxEmptyString is no-longer in mfc7 and above
		++id;
	}
}