Ejemplo n.º 1
0
bool CDirectoryTreeCtrl::HasSubdirectories(CString strDir)
{
	strDir += _T("*.*");

	CFileFind finder;
	BOOL bWorking = finder.FindFile(strDir);

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

		if (finder.IsDots())
			continue;
		if (finder.IsSystem())
			continue;
		if (!finder.IsDirectory())
			continue;

		finder.Close();

		return true;
	}

	finder.Close();
	return false;
}
Ejemplo n.º 2
0
void CDirectoryTreeCtrl::AddSubdirectories(HTREEITEM hRoot, CString strDir)
{
	strDir += _T("*.*");

	CFileFind finder;
	BOOL bWorking = finder.FindFile(strDir);

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

		if (finder.IsDots())
			continue;
		if (finder.IsSystem())
			continue;
		if (!finder.IsDirectory())
			continue;
		
		CString	strFilename = finder.GetFileName();
		int		iIdx;

		if ((iIdx = strFilename.ReverseFind('\\')) != -1)
			strFilename = strFilename.Mid(iIdx + 1);

		AddChildItem(hRoot, strFilename);
	}

	finder.Close();
}
Ejemplo n.º 3
0
void CSharedDirsTreeCtrl::AddSharedDirectory(CString strDir, bool bSubDirectories){
	if (!FileSystemTreeIsShared(strDir)){
		m_strliSharedDirs.AddTail(strDir);
	}
	if (bSubDirectories){
		if (strDir.Right(1) != _T("\\"))
			strDir += _T("\\");
		CFileFind finder;
		BOOL bWorking = finder.FindFile(strDir+_T("*.*"));
		while (bWorking)
		{
			bWorking = finder.FindNextFile();
			if (finder.IsDots() || finder.IsSystem() || !finder.IsDirectory())
				continue;
			AddSharedDirectory(strDir + finder.GetFileName(), true);
		}
		finder.Close();
	}
}
Ejemplo n.º 4
0
void CSharedDirsTreeCtrl::FileSystemTreeAddSubdirectories(CDirectoryItem* pRoot)
{
	CString strDir = pRoot->m_strFullPath;
	if (strDir.Right(1) != _T("\\"))
		strDir += _T("\\");
	CFileFind finder;
	BOOL bWorking = finder.FindFile(strDir+_T("*.*"));
	while (bWorking)
	{
		bWorking = finder.FindNextFile();
		if (finder.IsDots() || finder.IsSystem() || !finder.IsDirectory())
			continue;
		
		CString strFilename = finder.GetFileName();
		if (strFilename.ReverseFind(_T('\\')) != -1)
			strFilename = strFilename.Mid(strFilename.ReverseFind(_T('\\')) + 1);
		FileSystemTreeAddChildItem(pRoot, strFilename, false);
	}
	finder.Close();
}
Ejemplo n.º 5
0
bool CSharedDirsTreeCtrl::FileSystemTreeHasSubdirectories(CString strDir)
{
	if (strDir.Right(1) != _T('\\'))
		strDir += _T('\\');
	CFileFind finder;
	BOOL bWorking = finder.FindFile(strDir+_T("*.*"));
	while (bWorking)
	{
		bWorking = finder.FindNextFile();
		if (finder.IsDots())
			continue;
		if (finder.IsSystem())
			continue;
		if (!finder.IsDirectory())
			continue;
		finder.Close();
		return true;
	}
	finder.Close();
	return false;
}
Ejemplo n.º 6
0
BOOL CPPgDirectories::OnApply()
{
	bool testtempdirchanged=false;
	CString testincdirchanged = thePrefs.GetMuleDirectory(EMULE_INCOMINGDIR);

	CString strIncomingDir;
	GetDlgItemText(IDC_INCFILES, strIncomingDir);
	MakeFoldername(strIncomingDir);
	if (strIncomingDir.IsEmpty()){
		strIncomingDir = thePrefs.GetDefaultDirectory(EMULE_INCOMINGDIR, true); // will create the directory here if it doesnt exists
		SetDlgItemText(IDC_INCFILES, strIncomingDir);
	}
	else if (thePrefs.IsInstallationDirectory(strIncomingDir)){
		AfxMessageBox(GetResString(IDS_WRN_INCFILE_RESERVED));
		return FALSE;
	}
	else if (strIncomingDir.CompareNoCase(testincdirchanged) != 0 && strIncomingDir.CompareNoCase(thePrefs.GetDefaultDirectory(EMULE_INCOMINGDIR, false)) != 0){
		// if the user chooses a non-default directory which already contains files, inform him that all those files
		// will be shared
		CFileFind ff;
		CString strSearchPath;
		strSearchPath.Format(_T("%s\\*"),strIncomingDir);
		bool bEnd = !ff.FindFile(strSearchPath, 0);
		bool bExistingFile = false;
		while (!bEnd)
		{
			bEnd = !ff.FindNextFile();
			if (ff.IsDirectory() || ff.IsDots() || ff.IsSystem() || ff.IsTemporary() || ff.GetLength()==0 || ff.GetLength()>MAX_EMULE_FILE_SIZE)
				continue;

			// ignore real LNK files
			TCHAR szExt[_MAX_EXT];
			_tsplitpath(ff.GetFileName(), NULL, NULL, NULL, szExt);
			if (_tcsicmp(szExt, _T(".lnk")) == 0){
				SHFILEINFO info;
				if (SHGetFileInfo(ff.GetFilePath(), 0, &info, sizeof(info), SHGFI_ATTRIBUTES) && (info.dwAttributes & SFGAO_LINK)){
					if (!thePrefs.GetResolveSharedShellLinks())
						continue;
				}
			}

			// ignore real THUMBS.DB files -- seems that lot of ppl have 'thumbs.db' files without the 'System' file attribute
			if (ff.GetFileName().CompareNoCase(_T("thumbs.db")) == 0)
				continue;

			bExistingFile = true;
			break;
		}
		if (bExistingFile
			&& AfxMessageBox(GetResString(IDS_WRN_INCFILE_EXISTS), MB_OKCANCEL | MB_ICONINFORMATION) == IDCANCEL)
		{
			return FALSE;
		}
	}
	
	// checking specified tempdir(s)
	CString strTempDir;
	GetDlgItemText(IDC_TEMPFILES, strTempDir);
	if (strTempDir.IsEmpty()){
		strTempDir = thePrefs.GetDefaultDirectory(EMULE_TEMPDIR, true); // will create the directory here if it doesnt exists
		SetDlgItemText(IDC_TEMPFILES, strTempDir);
	}

	int curPos=0;
	CStringArray temptempfolders;
	CString atmp=strTempDir.Tokenize(_T("|"), curPos);
	while (!atmp.IsEmpty())
	{
		atmp.Trim();
		if (!atmp.IsEmpty()) {
			if (CompareDirectories(strIncomingDir, atmp)==0){
					AfxMessageBox(GetResString(IDS_WRN_INCTEMP_SAME));
					return FALSE;
			}	
			if (thePrefs.IsInstallationDirectory(atmp)){
				AfxMessageBox(GetResString(IDS_WRN_TEMPFILES_RESERVED));
				return FALSE;
			}
			bool doubled=false;
			for (int i=0;i<temptempfolders.GetCount();i++)	// avoid double tempdirs
				if (temptempfolders.GetAt(i).CompareNoCase(atmp)==0) {
					doubled=true;
					break;
				}
			if (!doubled) {
				temptempfolders.Add(atmp);
				if (thePrefs.tempdir.GetCount()>=temptempfolders.GetCount()) {
					if( atmp.CompareNoCase(thePrefs.GetTempDir(temptempfolders.GetCount()-1))!=0	)
						testtempdirchanged=true;
				} else testtempdirchanged=true;

			}
		}
		atmp = strTempDir.Tokenize(_T("|"), curPos);
	}

	if (temptempfolders.IsEmpty())
		temptempfolders.Add(strTempDir = thePrefs.GetDefaultDirectory(EMULE_TEMPDIR, true));

	if (temptempfolders.GetCount()!=thePrefs.tempdir.GetCount())
		testtempdirchanged=true;

	// applying tempdirs
	if (testtempdirchanged) {
		thePrefs.tempdir.RemoveAll();
		for (int i=0;i<temptempfolders.GetCount();i++) {
			CString toadd=temptempfolders.GetAt(i);
			MakeFoldername(toadd);
			if (!PathFileExists(toadd))
				CreateDirectory(toadd,NULL);
			if (PathFileExists(toadd))
				thePrefs.tempdir.Add(toadd);
		}
	}
	if (thePrefs.tempdir.IsEmpty())
		thePrefs.tempdir.Add(thePrefs.GetDefaultDirectory(EMULE_TEMPDIR, true));

	thePrefs.m_strIncomingDir = strIncomingDir;
	MakeFoldername(thePrefs.m_strIncomingDir);
	thePrefs.GetCategory(0)->strIncomingPath = thePrefs.GetMuleDirectory(EMULE_INCOMINGDIR);

	thePrefs.shareddir_list.RemoveAll();
	m_ShareSelector.GetSharedDirectories(&thePrefs.shareddir_list);
	for (int i = 0; i < m_ctlUncPaths.GetItemCount(); i++)
		thePrefs.shareddir_list.AddTail(m_ctlUncPaths.GetItemText(i, 0));

	// check shared directories for reserved folder names
	POSITION pos = thePrefs.shareddir_list.GetHeadPosition();
	while (pos){
		POSITION posLast = pos;
		const CString& rstrDir = thePrefs.shareddir_list.GetNext(pos);
		if (!thePrefs.IsShareableDirectory(rstrDir))
			thePrefs.shareddir_list.RemoveAt(posLast);
	}

	if (testtempdirchanged)
		AfxMessageBox(GetResString(IDS_SETTINGCHANGED_RESTART));
	
	// on changing incoming dir, update incoming dirs of category of the same path
	if (testincdirchanged.CompareNoCase(thePrefs.GetMuleDirectory(EMULE_INCOMINGDIR)) != 0) {
		CString oldpath;
		bool dontaskagain=false;
		for (int cat=1; cat<=thePrefs.GetCatCount()-1;cat++){
			oldpath=CString(thePrefs.GetCatPath(cat));
			if (oldpath.Left(testincdirchanged.GetLength()).CompareNoCase(testincdirchanged)==0) {

				if (!dontaskagain) {
					dontaskagain=true;
					if (AfxMessageBox(GetResString(IDS_UPDATECATINCOMINGDIRS),MB_YESNO)==IDNO)
						break;
				}
				thePrefs.GetCategory(cat)->strIncomingPath = thePrefs.GetMuleDirectory(EMULE_INCOMINGDIR) + oldpath.Mid(testincdirchanged.GetLength());
			}
		}
	}

	theApp.emuledlg->sharedfileswnd->Reload();
	
	SetModified(0);
	return CPropertyPage::OnApply();
}
//------------------------------------------------
// 파일의 리스트 및 각 파일에 대한 자세한 정보를 
// 함께 저장하게 됨
// 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();
	//-------------------------------------
}
Ejemplo n.º 8
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;

}
Ejemplo n.º 9
0
void CFileInfo::DirtoryInfoExtraction(const wstring& wstrPath, list<MESHPATH*>& rPathInfolist)
{
	CFileFind		Find;
	Find.FindFile(wstrPath.c_str());

	int		iContinue = 1;
	while(iContinue)
	{
		iContinue = Find.FindNextFile();

		if(Find.IsDots())
			continue;

		if(Find.IsDirectory())
			DirtoryInfoExtraction(wstring(Find.GetFilePath() + L"\\*.*"), rPathInfolist);
		else
		{
			if(Find.IsSystem())
				continue;

			MESHPATH*   pFilePath = new MESHPATH;
			ZeroMemory(pFilePath, sizeof(MESHPATH));

			TCHAR   szPathBuf[MAX_PATH] = L"";
			lstrcpy(szPathBuf, wstrPath.c_str());														//szPathBuf = 0x0013dd98 "C:\Users\Administrator.JUSIN-20150429V\Desktop\Export\Bush\Bush1\*.*"
			PathRemoveFileSpec(szPathBuf);		    													// szPathBuf = 0x0013dd98 "C:\Users\Administrator.JUSIN-20150429V\Desktop\Export\Bush\Bush1\*.*"
		

			wstring      wstrFileName = szPathBuf;														//szPathBuf = 0x0013dd98 "C:\Users\Administrator.JUSIN-20150429V\Desktop\Export\Bush\Bush1"
			wstrFileName = PathFindFileName(wstrFileName.c_str());										//wstrFileName = "Bush1"
			pFilePath->wstrObjTag = wstrFileName.c_str();         									// pFilePath = 0x11c5ff50 {wstrFileName="Bush1" wstrFilePath="" wstrFullPath="" ...}

			// 파일 이름 다시 정한다.
			while(true)
			{
				wstrFileName = Find.GetFilePath().operator LPCWSTR();									//wstrFileName = "C:\Users\Administrator.JUSIN-20150429V\Desktop\Export\Bush\Bush1\Bush1.X"

				wstring      wstrFileTag = wstrFileName.substr( wstrPath.find_last_of(L"\\") + 1 );		//wstrFileTag = "Bush1.X"
				wstrFileTag = wstrFileTag.substr(wstrFileTag.length() - 2, wstrFileTag.length());		//wstrFileTag = ".X"
				if(wstrFileTag == L".X" ||
					wstrFileTag == L".x")      // 대 소문자 구분하니까, 구분해서 찾아주기
				{
					wstrFileName = wstrFileName.substr( wstrPath.find_last_of(L"\\") + 1 );				//wstrFileName = "Bush1.X"
					pFilePath->wstrFileTag = wstrFileName.c_str();      // 파일이름						//pFilePath->wstrType = "Bush1.X"
					break;
				}
				Find.FindNextFile();
			}
			//          wstrFileName = wstrFileName + L".X";
			//          lstrcpy(pFilePath->szFileTag, wstrFileName.c_str());      // 파일이름

			TCHAR   szBuf[MAX_PATH] = L"";
			lstrcpy(szBuf, (LPWSTR)Find.GetFilePath().operator LPCWSTR());								//szBuf = 0x0013db38 "C:\Users\Administrator.JUSIN-20150429V\Desktop\Export\Bush\Bush1\Bush1.X"
			PathRemoveFileSpec(szBuf);																	//szBuf = 0x0013db38 "C:\Users\Administrator.JUSIN-20150429V\Desktop\Export\Bush\Bush1"

			PathCombine(szBuf, szBuf, (LPWSTR)wstrFileName.c_str());									//szBuf = 0x0013db38 "C:\Users\Administrator.JUSIN-20150429V\Desktop\Export\Bush\Bush1\Bush1.X"
			PathRemoveFileSpec(szBuf);																	//szBuf = 0x0013db38 "C:\Users\Administrator.JUSIN-20150429V\Desktop\Export\Bush\Bush1"
			//PathRemoveFileSpec(szBuf);
			pFilePath->wstrFullPath = ConvertRelativePath(szBuf).c_str();								//pFilePath->wstrFullPath = "..\..\..\..\Export\Bush\Bush1"
			// 마지막 파일 이름 없애야 함

			PathRemoveFileSpec(szBuf);																	//szBuf = 0x0013db38 "C:\Users\Administrator.JUSIN-20150429V\Desktop\Export\Bush"
			pFilePath->wstrGroupTag = PathFindFileName(szBuf);											//pFilePath->wstrFilePath = "Bush"


			pFilePath->wstrFullPath += L"\\";      // 마지막에 하나 붙여주자							//pFilePath->wstrFullPath = "..\..\..\..\Export\Bush\Bush1\"
			rPathInfolist.push_back(pFilePath);															//pFilePath = 0x11c5ff50 {wstrFileName="Bush1" wstrFilePath="Bush" wstrFullPath="..\..\..\..\Export\Bush\Bush1\" ...}

			Find.FindFile(Find.GetFilePath());
			Find.FindNextFile();
		}
	}
}