示例#1
0
void DeleteFolder(CString dir)
{
	if(FileIsDirectory(dir))
	{
		//SHFILEOPSTRUCT   Op;
		//ZeroMemory(&Op,   sizeof(Op));   //删除文件夹
		//Op.hwnd   =   NULL; 
		//Op.wFunc   =   FO_DELETE;
		//Op.pFrom   =   dir;
		//Op.fFlags   =   FOF_ALLOWUNDO   |   FOF_NOCONFIRMATION;     
		//SHFileOperation(&Op);

		CFindFile   tempFind;
		CString   tempFileFind;
		tempFileFind.Format(_T("%s\\*.*"),dir);
		BOOL   IsFinded   =   tempFind.FindFile(tempFileFind);
		while   (IsFinded)
		{
			IsFinded   =   tempFind.FindNextFile();
			if(!tempFind.IsDots())
			{
				if(tempFind.IsDirectory())
					DeleteFolder(tempFind.GetFilePath());
				else
					DeleteFile(tempFind.GetFilePath());
			}
		}
		tempFind.Close();
		RemoveDirectory(dir);
	}
}
示例#2
0
			// #ifndef _UNICODE
			bool CFileInfoW::Find(LPCWSTR wildcard)
			{
#ifdef SUPPORT_DEVICE_FILE
				if (IsDeviceName(wildcard))
				{
					Clear();
					IsDevice = true;
					NIO::CInFile inFile;
					if (!inFile.Open(wildcard))
      return false;
					Name = wildcard + 4;
					if (inFile.LengthDefined)
      Size = inFile.Length;
					return true;
				}
#endif
				CFindFile finder;
				return finder.FindFirst(wildcard, *this);
			}
示例#3
0
bool UtilPathExpandWild(std::list<CString> &r_outList,const CString &r_inParam)
{
	std::list<CString> tempList;
	if(-1==r_inParam.FindOneOf(_T("*?"))){	//ワイルド展開可能な文字はない
		tempList.push_back(r_inParam);
	}else{
		//ワイルド展開
		CFindFile cFindFile;
		BOOL bContinue=cFindFile.FindFile(r_inParam);
		while(bContinue){
			if(!cFindFile.IsDots()){
				tempList.push_back(cFindFile.GetFilePath());
			}
			bContinue=cFindFile.FindNextFile();
		}
	}
	r_outList=tempList;
	return true;
}
示例#4
0
//=============================================================================
// 函数名称:	移动覆盖一个指定的目录
// 作者说明:	mushuai
// 修改时间:	2013-03-14
//=============================================================================
int ConvertPath(LPCTSTR srcpath,LPCTSTR targpath)
{
	int iresult = 1;
	CFindFile finder;
	if(finder.FindFile(srcpath))
	{
		CString fileName,filePath;
		do
		{
			fileName=finder.GetFileName();
			filePath = finder.GetFilePath();
			//. ..
			if (finder.IsDots())
			{
				continue;
			}
			//dir
			else if (finder.IsDirectory())
			{
				CString tTargPath = targpath;
				tTargPath +=_T("\\")+fileName;
				ConvertPath(filePath+_T("\\*"),tTargPath);
				RemoveDirectory(filePath);
			}
			else//file
			{
				CString newFilePath = targpath;
				newFilePath +=_T("\\")+fileName;					
				if (!PathFileExists(targpath))
				{
					if(ERROR_SUCCESS != SHCreateDirectoryEx(0,targpath,0))
					{
						return 0;
					}
				}
				BOOL res=MoveFileEx(filePath,newFilePath,MOVEFILE_COPY_ALLOWED | MOVEFILE_REPLACE_EXISTING);
				if (!res)
				{
					SetFileAttributes(newFilePath,FILE_ATTRIBUTE_NORMAL);
					if (!DeleteFile(newFilePath))
					{
						MoveFileEx(filePath,newFilePath,MOVEFILE_COPY_ALLOWED | MOVEFILE_REPLACE_EXISTING);
					}
				}
			}
		}while (finder.FindNextFile());
	}
	finder.Close();
	return iresult;
}
示例#5
0
//ワイルドカードの展開
bool UtilPathExpandWild(std::list<CString> &r_outList,const std::list<CString> &r_inList)
{
	std::list<CString> tempList;
	std::list<CString>::const_iterator ite=r_inList.begin();
	const std::list<CString>::const_iterator end=r_inList.end();
	for(;ite!=end;++ite){
		if(-1==(*ite).FindOneOf(_T("*?"))){	//ワイルド展開可能な文字はない
			tempList.push_back(*ite);
		}else{
			//ワイルド展開
			CFindFile cFindFile;
			BOOL bContinue=cFindFile.FindFile(*ite);
			while(bContinue){
				if(!cFindFile.IsDots()){
					tempList.push_back(cFindFile.GetFilePath());
				}
				bContinue=cFindFile.FindNextFile();
			}
		}
	}
	r_outList=tempList;
	return true;
}
示例#6
0
int CPhotoEngine::_PopulateList(LPCTSTR szPath)
{
	const int count = 0;
	BOOL bRes;
	CFindFile ff;
	CString sPattern;
	sPattern.Format(_T("%s\\*.jpg"), szPath);
	for( bRes = ff.FindFile(sPattern); bRes; bRes = ff.FindNextFile() )
	{
		if( ff.IsDirectory() ) continue;
		AddImageFile(ff.GetFilePath(), ff.GetFileName());
	}

	return 0;
}
示例#7
0
//フォルダ内ファイル(ディレクトリは除く)を再帰検索
bool UtilRecursiveEnumFile(LPCTSTR lpszRoot,std::list<CString> &rFileList)
{
	CFindFile cFindFile;
	TCHAR szPath[_MAX_PATH+1];
	_tcsncpy_s(szPath,lpszRoot,_MAX_PATH);
	PathAppend(szPath,_T("*"));

	BOOL bContinue=cFindFile.FindFile(szPath);
	while(bContinue){
		if(!cFindFile.IsDots()){
			if(cFindFile.IsDirectory()){
				UtilRecursiveEnumFile(cFindFile.GetFilePath(),rFileList);
			}else{
				rFileList.push_back(cFindFile.GetFilePath());
			}
		}
		bContinue=cFindFile.FindNextFile();
	}

	return !rFileList.empty();
}
示例#8
0
void MenuCommand_MakeSendToCommands()
{
	TCHAR szSendTo[_MAX_PATH];
	std::vector<CString> files;
	if(SHGetSpecialFolderPath(NULL,szSendTo,CSIDL_SENDTO,FALSE)){
		PathAddBackslash(szSendTo);
		PathAppend(szSendTo,_T("*.lnk"));
		CFindFile cFind;

		BOOL bFound=cFind.FindFile(szSendTo);
		for(;bFound;bFound=cFind.FindNextFile()){
			if(cFind.IsDots())continue;

			if(!cFind.IsDirectory()){	//サブディレクトリ検索はしない
				files.push_back(cFind.GetFilePath());
			}
		}
	}

	UtilGetShortcutInfo(files,s_SendToCmd);
}
示例#9
0
void CMacFindFile::TestFF(const char *directorypath, const char *pfilter)
{
	CFindFile*				pFileFinder =NULL;
	char * pszDllName;
	int count = 0;
	CHXString s1;
	Str255 s1Pasc;
	
	pFileFinder = CFindFile::CreateFindFile(directorypath, 0, pfilter);
	pszDllName = pFileFinder->FindFirst();
	while (pszDllName)
	{
		count ++;

		CHXString s2;
		s2.Format("%s: %d %s\r", pfilter, (short) count, pszDllName);
		if (s1.GetLength() + s2.GetLength() > 255)
		{
			s1.MakeStr255(s1Pasc);
			DebugStr(s1Pasc);
			s1.Empty();
		}
		s1 += s2;
	

		char *path = pFileFinder->GetCurFilePath();
		char *filename = pFileFinder->GetCurFilename();
		char *dirpath = pFileFinder->GetCurDirectory();
		
		pszDllName = pFileFinder->FindNext();
		
	}
	delete pFileFinder;

	s1.MakeStr255(s1Pasc);
	DebugStr(s1Pasc);
}
示例#10
0
int CCrashInfoReader::Init(LPCTSTR szFileMappingName)
{ 
	// This method unpacks crash information from a shared memory (file-mapping)
	// and inits the internal variables.

	strconv_t strconv;
    CErrorReportInfo eri;

	// Init shared memory
	if(!m_SharedMem.IsInitialized())
	{
		// Init shared memory
		BOOL bInitMem = m_SharedMem.Init(szFileMappingName, TRUE, 0);
		if(!bInitMem)
		{
			m_sErrorMsg = _T("Error initializing shared memory.");
			return 1;
		}
	}

	// Unpack crash description from shared memory
    m_pCrashDesc = (CRASH_DESCRIPTION*)m_SharedMem.CreateView(0, sizeof(CRASH_DESCRIPTION));

    int nUnpack = UnpackCrashDescription(eri);
    if(0!=nUnpack)
    {
		m_sErrorMsg = _T("Error unpacking crash description.");
        return 2;
    }
	
	// Create LOCAL_APP_DATA\UnsentCrashReports folder (if doesn't exist yet).
    BOOL bCreateFolder = Utility::CreateFolder(m_sUnsentCrashReportsFolder);
    if(!bCreateFolder)
        return 3;

	// Save path to INI file storing settings
    m_sINIFile = m_sUnsentCrashReportsFolder + _T("\\~CrashRpt.ini");          

    if(!m_bSendRecentReports) // We should send report immediately
    { 
        CollectMiscCrashInfo(eri);

        eri.m_sErrorReportDirName = m_sUnsentCrashReportsFolder + _T("\\") + eri.m_sCrashGUID;
        Utility::CreateFolder(eri.m_sErrorReportDirName);		

        m_Reports.push_back(eri);
    }  
    else // We should look for pending error reports
    {
        // Unblock the parent process
        CString sEventName;
        sEventName.Format(_T("Local\\CrashRptEvent_%s"), eri.m_sCrashGUID);
        HANDLE hEvent = CreateEvent(NULL, FALSE, FALSE, sEventName);
        if(hEvent!=NULL)
            SetEvent(hEvent);

        // Look for pending error reports and add them to the list
        CString sSearchPattern = m_sUnsentCrashReportsFolder + _T("\\*");
        CFindFile find;
        BOOL bFound = find.FindFile(sSearchPattern);
        while(bFound)
        {
            if(find.IsDirectory() && !find.IsDots()) // Process directories only
            {
                CString sErrorReportDirName = m_sUnsentCrashReportsFolder + _T("\\") + 
                    find.GetFileName();
                CString sFileName = sErrorReportDirName + _T("\\crashrpt.xml");
                CErrorReportInfo eri2;
                eri2.m_sErrorReportDirName = sErrorReportDirName;
				// Read crash description XML from the directory
                if(0==ParseCrashDescription(sFileName, TRUE, eri2))
                {          
					// Calculate crash report size
                    eri2.m_uTotalSize = GetUncompressedReportSize(eri2);
					// Add report to the list
                    m_Reports.push_back(eri2);
                }
            }

            bFound = find.FindNextFile();
        }
    }

	// Done
    return 0;
}
示例#11
0
bool FindFile(LPCWSTR wildcard, CFileInfoW &fileInfo)
{
  CFindFile finder;
  return finder.FindFirst(wildcard, fileInfo);
}
示例#12
0
int CCrashInfoReader::Init(CString sCrashInfoFileName)
{ 
  strconv_t strconv;
  ErrorReportInfo eri;
  
  TiXmlDocument doc;
  bool bOpen = doc.LoadFile(strconv.t2a(sCrashInfoFileName));
  if(!bOpen)
    return 1;

  TiXmlHandle hRoot = doc.FirstChild("CrashRptInternal");
  if(hRoot.ToElement()==NULL)
    return 1;

  {    
    TiXmlHandle hUnsentCrashReportsFolder = hRoot.FirstChild("UnsentCrashReportsFolder");
    if(hUnsentCrashReportsFolder.FirstChild().ToText()!=NULL)
    {      
      const char* szUnsentCrashReportsFolder = hUnsentCrashReportsFolder.FirstChild().ToText()->Value();
      if(szUnsentCrashReportsFolder!=NULL)
      {
        m_sUnsentCrashReportsFolder = strconv.utf82t(szUnsentCrashReportsFolder);
        Utility::CreateFolder(m_sUnsentCrashReportsFolder);
        
        m_sINIFile = m_sUnsentCrashReportsFolder + _T("\\~CrashRpt.ini");        
      }
    }
  }  
  
  {
    TiXmlHandle hReportFolder = hRoot.FirstChild("ReportFolder");
    if(hReportFolder.FirstChild().ToText()!=NULL)
    {
      const char* szReportFolder = hReportFolder.FirstChild().ToText()->Value();
      if(szReportFolder!=NULL)
        eri.m_sErrorReportDirName = strconv.utf82t(szReportFolder);
    }
  }

  {
    m_bQueueEnabled = FALSE;
    TiXmlHandle hQueueEnabled = hRoot.FirstChild("QueueEnabled");
    if(hQueueEnabled.FirstChild().ToText()!=NULL)
    {      
      const char* szQueueEnabled = hQueueEnabled.FirstChild().ToText()->Value();
      if(szQueueEnabled!=NULL)
      {
        m_bQueueEnabled = atoi(szQueueEnabled);        
      }
    }
  }  

  {
    m_bSendRecentReports = FALSE;
    TiXmlHandle hSendRecentReports = hRoot.FirstChild("SendRecentReports");
    if(hSendRecentReports.FirstChild().ToText()!=NULL)
    {      
      const char* szSendRecentReports = hSendRecentReports.FirstChild().ToText()->Value();
      if(szSendRecentReports!=NULL)
      {
        m_bSendRecentReports = atoi(szSendRecentReports);        
      }
    }
  }  


  {
    TiXmlHandle hCrashGUID = hRoot.FirstChild("CrashGUID");
    if(hCrashGUID.FirstChild().ToText()!=NULL)
    {
      const char* szCrashGUID = hCrashGUID.FirstChild().ToText()->Value();
      if(szCrashGUID!=NULL)
        eri.m_sCrashGUID = strconv.utf82t(szCrashGUID);
    }
  }

  {
    TiXmlHandle hAppName = hRoot.FirstChild("AppName");
    if(hAppName.FirstChild().ToText()!=NULL)
    {
      const char* szAppName = hAppName.FirstChild().ToText()->Value();
      if(szAppName!=NULL)
        m_sAppName = strconv.utf82t(szAppName);
    }
  }

  {
    TiXmlHandle hLangFileName = hRoot.FirstChild("LangFileName");
    if(hLangFileName.FirstChild().ToText()!=NULL)
    {
      const char* szLangFileName = hLangFileName.FirstChild().ToText()->Value();
      if(szLangFileName!=NULL)
        m_sLangFileName = strconv.utf82t(szLangFileName);
    }
  }

  {
    TiXmlHandle hDbgHelpPath = hRoot.FirstChild("DbgHelpPath");
    if(hDbgHelpPath.FirstChild().ToText()!=NULL)
    {
      const char* szDbgHelpPath = hDbgHelpPath.FirstChild().ToText()->Value();
      if(szDbgHelpPath!=NULL)
        m_sDbgHelpPath = strconv.utf82t(szDbgHelpPath);
    }
  }

  {
    m_bGenerateMinidump = TRUE;
    TiXmlHandle hGenerateMinidump = hRoot.FirstChild("GenerateMinidump");
    if(hGenerateMinidump.FirstChild().ToText()!=NULL)
    {
      const char* szGenerateMinidump = hGenerateMinidump.FirstChild().ToText()->Value();
      if(szGenerateMinidump!=NULL)
        m_bGenerateMinidump = (MINIDUMP_TYPE)atol(szGenerateMinidump);      
    }    
  }

  {
    TiXmlHandle hMinidumpType = hRoot.FirstChild("MinidumpType");
    if(hMinidumpType.FirstChild().ToText()!=NULL)
    {
      const char* szMinidumpType = hMinidumpType.FirstChild().ToText()->Value();
      if(szMinidumpType!=NULL)
        m_MinidumpType = (MINIDUMP_TYPE)atol(szMinidumpType);
      else
        m_MinidumpType = MiniDumpNormal;
    }
    else
      m_MinidumpType = MiniDumpNormal;
  }

  {
    TiXmlHandle hUrl = hRoot.FirstChild("Url");
    if(hUrl.FirstChild().ToText()!=NULL)
    {
      const char* szUrl = hUrl.FirstChild().ToText()->Value();
      if(szUrl!=NULL)
        m_sUrl = strconv.utf82t(szUrl);
    }
  }

  {
    TiXmlHandle hEmailTo = hRoot.FirstChild("EmailTo");
    if(hEmailTo.FirstChild().ToText()!=NULL)
    {
      const char* szEmailTo = hEmailTo.FirstChild().ToText()->Value();
      if(szEmailTo!=NULL)
        m_sEmailTo = strconv.utf82t(szEmailTo);
    }
  }

  {
    m_nSmtpPort = 25;
    TiXmlHandle hSmtpPort = hRoot.FirstChild("SmtpPort");
    if(hSmtpPort.FirstChild().ToText()!=NULL)
    {
      const char* szSmtpPort = hSmtpPort.FirstChild().ToText()->Value();
      if(szSmtpPort!=NULL)
        m_nSmtpPort = atoi(szSmtpPort);
    }
  }

  {
    TiXmlHandle hEmailSubject = hRoot.FirstChild("EmailSubject");
    if(hEmailSubject.FirstChild().ToText()!=NULL)
    {
      const char* szEmailSubject = hEmailSubject.FirstChild().ToText()->Value();
      if(szEmailSubject!=NULL)
        m_sEmailSubject = strconv.utf82t(szEmailSubject);
    }
  }

  {
    TiXmlHandle hEmailText = hRoot.FirstChild("EmailText");
    if(hEmailText.FirstChild().ToText()!=NULL)
    {
      const char* szEmailText = hEmailText.FirstChild().ToText()->Value();
      if(szEmailText!=NULL)
        m_sEmailText = strconv.utf82t(szEmailText);
    }
  }

  {
    TiXmlHandle hPrivacyPolicyUrl = hRoot.FirstChild("PrivacyPolicyUrl");    
    if(hPrivacyPolicyUrl.FirstChild().ToText()!=NULL)
    {
      const char* szPrivacyPolicyUrl = hPrivacyPolicyUrl.FirstChild().ToText()->Value();
      if(szPrivacyPolicyUrl!=NULL)
        m_sPrivacyPolicyURL = strconv.utf82t(szPrivacyPolicyUrl);
    }
  }

  {
    TiXmlHandle hHttpPriority = hRoot.FirstChild("HttpPriority");
    if(hHttpPriority.FirstChild().ToText()!=NULL)
    {
      const char* szHttpPriority = hHttpPriority.FirstChild().ToText()->Value();
      if(szHttpPriority!=NULL)
        m_uPriorities[CR_HTTP] = atoi(szHttpPriority);
      else
        m_uPriorities[CR_HTTP] = 0;
    }
  }

  {
    TiXmlHandle hSmtpPriority = hRoot.FirstChild("SmtpPriority");
    if(hSmtpPriority.FirstChild().ToText()!=NULL)
    {
      const char* szSmtpPriority = hSmtpPriority.FirstChild().ToText()->Value();
      if(szSmtpPriority!=NULL)
        m_uPriorities[CR_SMTP] = atoi(szSmtpPriority);
      else
        m_uPriorities[CR_SMTP] = 0;
    }
  }

  {
    TiXmlHandle hMapiPriority = hRoot.FirstChild("MapiPriority");
    if(hMapiPriority.FirstChild().ToText()!=NULL)
    {
      const char* szMapiPriority = hMapiPriority.FirstChild().ToText()->Value();
      if(szMapiPriority!=NULL)
        m_uPriorities[CR_SMAPI] = atoi(szMapiPriority);
      else
        m_uPriorities[CR_SMAPI] = 0;
    }
  }

  {
    TiXmlHandle hProcessId = hRoot.FirstChild("ProcessId");
    if(hProcessId.FirstChild().ToText()!=NULL)
    {
      const char* szProcessId = hProcessId.FirstChild().ToText()->Value();
      if(szProcessId!=NULL)
        m_dwProcessId = strtoul(szProcessId, NULL, 10);
      else
        m_dwProcessId = 0;
    }
  }

  {
    TiXmlHandle hThreadId = hRoot.FirstChild("ThreadId");
    if(hThreadId.FirstChild().ToText()!=NULL)
    {
      const char* szThreadId = hThreadId.FirstChild().ToText()->Value();
      if(szThreadId!=NULL)
        m_dwThreadId = strtoul(szThreadId, NULL, 10);
      else 
        m_dwThreadId = 0;
    }
  }

  {
    m_pExInfo = NULL;
    TiXmlHandle hExceptionPointersAddress = hRoot.FirstChild("ExceptionPointersAddress");
    if(hExceptionPointersAddress.FirstChild().ToText()!=NULL)
    {
      const char* szExceptionPointersAddress = hExceptionPointersAddress.FirstChild().ToText()->Value();
      if(szExceptionPointersAddress!=NULL)
        m_pExInfo = (PEXCEPTION_POINTERS)_strtoui64(szExceptionPointersAddress, NULL, 16);     
    }    
  }

  {
    TiXmlHandle hAddScreenshot = hRoot.FirstChild("AddScreenshot");
    if(hAddScreenshot.FirstChild().ToText()!=NULL)
    {
      const char* szAddScreenshot = hAddScreenshot.FirstChild().ToText()->Value();
      if(szAddScreenshot!=NULL)
        m_bAddScreenshot = strtol(szAddScreenshot, NULL, 10);
      else
        m_bAddScreenshot = FALSE;
    }
  }

  {
    m_dwScreenshotFlags = 0;
    TiXmlHandle hScreenshotFlags = hRoot.FirstChild("ScreenshotFlags");
    if(hScreenshotFlags.FirstChild().ToText()!=NULL)
    {
      const char* szScreenshotFlags = hScreenshotFlags.FirstChild().ToText()->Value();
      if(szScreenshotFlags!=NULL)
        m_dwScreenshotFlags = strtoul(szScreenshotFlags, NULL, 10);        
    }
  }

  {
    m_ptCursorPos.SetPoint(0, 0);
    TiXmlHandle hCursorPos = hRoot.FirstChild("CursorPos");
    if(hCursorPos.ToElement()!=NULL)
    {
      const char* szX = hCursorPos.ToElement()->Attribute("x");
      const char* szY = hCursorPos.ToElement()->Attribute("y");
      if(szX && szY)
      {
        m_ptCursorPos.x = atoi(szX);
        m_ptCursorPos.y = atoi(szY);
      }
    }
  }

  {
    m_rcAppWnd.SetRectEmpty();
    TiXmlHandle hAppWndRect = hRoot.FirstChild("AppWindowRect");
    if(hAppWndRect.ToElement()!=NULL)
    {
      const char* szLeft = hAppWndRect.ToElement()->Attribute("left");
      const char* szTop = hAppWndRect.ToElement()->Attribute("top");
      const char* szRight = hAppWndRect.ToElement()->Attribute("right");
      const char* szBottom = hAppWndRect.ToElement()->Attribute("bottom");

      if(szLeft && szTop && szRight && szBottom)
      {
        m_rcAppWnd.left = atoi(szLeft);
        m_rcAppWnd.top = atoi(szTop);
        m_rcAppWnd.right = atoi(szRight);
        m_rcAppWnd.bottom = atoi(szBottom);
      }
    }
  }

  {
    m_bHttpBinaryEncoding = FALSE;    
    TiXmlHandle hHttpBinaryEncoding = hRoot.FirstChild("HttpBinaryEncoding");
    if(hHttpBinaryEncoding.FirstChild().ToText()!=NULL)
    {
      const char* szHttpBinaryEncoding = hHttpBinaryEncoding.FirstChild().ToText()->Value();
      if(szHttpBinaryEncoding!=NULL)
        m_bHttpBinaryEncoding = atoi(szHttpBinaryEncoding);
    }      
  }

  {
    m_bSilentMode = FALSE;    
    TiXmlHandle hSilentMode = hRoot.FirstChild("SilentMode");
    if(hSilentMode.FirstChild().ToText()!=NULL)
    {
      const char* szSilentMode = hSilentMode.FirstChild().ToText()->Value();
      if(szSilentMode!=NULL)
        m_bSilentMode = atoi(szSilentMode);
    }      
  }

  {
    m_bSendErrorReport = FALSE;    
    TiXmlHandle hSendErrorReport = hRoot.FirstChild("SendErrorReport");
    if(hSendErrorReport.FirstChild().ToText()!=NULL)
    {
      const char* szSendErrorReport = hSendErrorReport.FirstChild().ToText()->Value();
      if(szSendErrorReport!=NULL)
        m_bSendErrorReport = atoi(szSendErrorReport);     
    }      
  }

  {
    m_bAppRestart = FALSE;    
    TiXmlHandle hAppRestart = hRoot.FirstChild("AppRestart");
    if(hAppRestart.FirstChild().ToText()!=NULL)
    {
      const char* szAppRestart = hAppRestart.FirstChild().ToText()->Value();
      if(szAppRestart!=NULL)
        m_bAppRestart = atoi(szAppRestart);     
    }      
  }

  {    
    TiXmlHandle hRestartCmdLine = hRoot.FirstChild("RestartCmdLine");
    if(hRestartCmdLine.FirstChild().ToText()!=NULL)
    {
      const char* szRestartCmdLine = hRestartCmdLine.FirstChild().ToText()->Value();
      if(szRestartCmdLine!=NULL)
        m_sRestartCmdLine = strconv.utf82t(szRestartCmdLine);     
    }      
  }

  {    
    TiXmlHandle hSmtpProxyServer = hRoot.FirstChild("SmtpProxyServer");
    if(hSmtpProxyServer.FirstChild().ToText()!=NULL)
    {
      const char* szSmtpProxyServer = hSmtpProxyServer.FirstChild().ToText()->Value();
      if(szSmtpProxyServer!=NULL)
        m_sSmtpProxyServer = strconv.utf82t(szSmtpProxyServer);     
    }      
  }

  {    
    m_nSmtpProxyPort = 25;
    TiXmlHandle hSmtpProxyPort = hRoot.FirstChild("SmtpProxyPort");
    if(hSmtpProxyPort.FirstChild().ToText()!=NULL)
    {
      const char* szSmtpProxyPort = hSmtpProxyPort.FirstChild().ToText()->Value();
      if(szSmtpProxyPort!=NULL)
        m_nSmtpProxyPort = atoi(szSmtpProxyPort);     
    }      
  }

  if(!m_bSendRecentReports)
  {    
    // Get the list of files that should be included to report
    ParseFileList(hRoot, eri);

    // Get some info from crashrpt.xml
    CString sXmlName = eri.m_sErrorReportDirName + _T("\\crashrpt.xml");
    ParseCrashDescription(sXmlName, FALSE, eri);    
    
    m_Reports.push_back(eri);
  }  
  else
  {
    // Look for unsent error reports
    CString sSearchPattern = m_sUnsentCrashReportsFolder + _T("\\*");
    CFindFile find;
    BOOL bFound = find.FindFile(sSearchPattern);
    while(bFound)
    {
      if(find.IsDirectory() && !find.IsDots())
      {
        CString sErrorReportDirName = m_sUnsentCrashReportsFolder + _T("\\") + 
          find.GetFileName();
        CString sFileName = sErrorReportDirName + _T("\\crashrpt.xml");
        ErrorReportInfo eri;
        eri.m_sErrorReportDirName = sErrorReportDirName;
        if(0==ParseCrashDescription(sFileName, TRUE, eri))
        {          
          eri.m_uTotalSize = GetUncompressedReportSize(eri);
          m_Reports.push_back(eri);
        }
      }

      bFound = find.FindNextFile();
    }
  }
  
  return 0;
}
示例#13
0
bool CClientApp::EnumAllFiles(string sFolder)
{
	if ( sFolder.length() == 0 )
		return false;

	bool bRet = false;
	CFindFile fFind;
	string sFindStr = sFolder + "\\*.*";
	BOOL bFind = fFind.FindFile( sFindStr.c_str() );
	while ( bFind )
	{
		bRet = true;

		if ( fFind.IsDirectory() )
		{
			if ( !fFind.IsDots() )
			{
				if ( !EnumAllFiles( fFind.GetFilePath().GetBuffer(0) ) )
				{
					bRet = false;
					break;
				}
			}
		}
		else
		{
			CMediaFile* pMediaFile = new CMediaFile();
			if ( pMediaFile )
			{
				if ( pMediaFile->InitFile( fFind.GetFilePath().GetBuffer(0), fFind.GetFileName().GetBuffer(0) ) )
				{
					pMediaFile->m_sNodeName = "Kevin_Test_Node_Name";
					m_MediaFileMgr.Insert( pMediaFile->m_sFileHash, pMediaFile );
					// 查找到立即发布
					PublishFiles();
				}
				else
				{
					delete pMediaFile;
					CKLog::WriteLog( LOG_TYPE_DEBUG, "%s InitFile Failed.", fFind.GetFilePath() );
					WriteLog( LOG_TYPE_DEBUG, "%s InitFile Failed.", fFind.GetFilePath() );
				}
			}
		}

		bFind = fFind.FindNextFile();
	}
	fFind.Close();

	return bRet;
}
示例#14
0
bool CFileInfo::Find(CFSTR path)
{
  #ifdef SUPPORT_DEVICE_FILE
  if (IsDevicePath(path))
  {
    ClearBase();
    Name = path + 4;
    IsDevice = true;
    
    if (NName::IsDrivePath2(path + 4) && path[6] == 0)
    {
      FChar drive[4] = { path[4], ':', '\\', 0 };
      UInt64 clusterSize, totalSize, freeSize;
      if (NSystem::MyGetDiskFreeSpace(drive, clusterSize, totalSize, freeSize))
      {
        Size = totalSize;
        return true;
      }
    }

    NIO::CInFile inFile;
    // ::OutputDebugStringW(path);
    if (!inFile.Open(path))
      return false;
    // ::OutputDebugStringW(L"---");
    if (inFile.SizeDefined)
      Size = inFile.Size;
    return true;
  }
  #endif

  #if defined(_WIN32) && !defined(UNDER_CE)

  int colonPos = FindAltStreamColon(path);
  if (colonPos >= 0 && path[(unsigned)colonPos + 1] != 0)
  {
    UString streamName = fs2us(path + (unsigned)colonPos);
    FString filePath = path;
    filePath.DeleteFrom(colonPos);
    /* we allow both cases:
      name:stream
      name:stream:$DATA
    */
    const unsigned kPostfixSize = 6;
    if (streamName.Len() <= kPostfixSize
        || !StringsAreEqualNoCase_Ascii(streamName.RightPtr(kPostfixSize), ":$DATA"))
      streamName += L":$DATA";

    bool isOk = true;
    
    if (IsDrivePath2(filePath) &&
        (colonPos == 2 || colonPos == 3 && filePath[2] == '\\'))
    {
      // FindFirstFile doesn't work for "c:\" and for "c:" (if current dir is ROOT)
      ClearBase();
      Name.Empty();
      if (colonPos == 2)
        Name = filePath;
    }
    else
      isOk = Find(filePath);

    if (isOk)
    {
      Attrib &= ~(FILE_ATTRIBUTE_DIRECTORY | FILE_ATTRIBUTE_REPARSE_POINT);
      Size = 0;
      CStreamEnumerator enumerator(filePath);
      for (;;)
      {
        CStreamInfo si;
        bool found;
        if (!enumerator.Next(si, found))
          return false;
        if (!found)
        {
          ::SetLastError(ERROR_FILE_NOT_FOUND);
          return false;
        }
        if (si.Name.IsEqualTo_NoCase(streamName))
        {
          // we delete postfix, if alt stream name is not "::$DATA"
          if (si.Name.Len() > kPostfixSize + 1)
            si.Name.DeleteFrom(si.Name.Len() - kPostfixSize);
          Name += us2fs(si.Name);
          Size = si.Size;
          IsAltStream = true;
          return true;
        }
      }
    }
  }
  
  #endif

  CFindFile finder;

  #if defined(_WIN32) && !defined(UNDER_CE)
  {
    /*
    DWORD lastError = GetLastError();
    if (lastError == ERROR_FILE_NOT_FOUND
        || lastError == ERROR_BAD_NETPATH  // XP64: "\\Server\Share"
        || lastError == ERROR_BAD_NET_NAME // Win7: "\\Server\Share"
        || lastError == ERROR_INVALID_NAME // XP64: "\\?\UNC\Server\Share"
        || lastError == ERROR_BAD_PATHNAME // Win7: "\\?\UNC\Server\Share"
        )
    */
    
    unsigned rootSize = 0;
    if (IsSuperPath(path))
      rootSize = kSuperPathPrefixSize;
    
    if (NName::IsDrivePath(path + rootSize) && path[rootSize + 3] == 0)
    {
      DWORD attrib = GetFileAttrib(path);
      if (attrib != INVALID_FILE_ATTRIBUTES && (attrib & FILE_ATTRIBUTE_DIRECTORY) != 0)
      {
        ClearBase();
        Attrib = attrib;
        Name = path + rootSize;
        Name.DeleteFrom(2); // we don't need backslash (C:)
        return true;
      }
    }
    else if (IS_PATH_SEPAR(path[0]))
      if (path[1] == 0)
      {
        DWORD attrib = GetFileAttrib(path);
        if (attrib != INVALID_FILE_ATTRIBUTES && (attrib & FILE_ATTRIBUTE_DIRECTORY) != 0)
        {
          ClearBase();
          Name.Empty();
          Attrib = attrib;
          return true;
        }
      }
      else
      {
        const unsigned prefixSize = GetNetworkServerPrefixSize(path);
        if (prefixSize > 0 && path[prefixSize] != 0)
        {
          if (NName::FindSepar(path + prefixSize) < 0)
          {
            FString s = path;
            s.Add_PathSepar();
            s += FCHAR_ANY_MASK;
            
            bool isOK = false;
            if (finder.FindFirst(s, *this))
            {
              if (Name == FTEXT("."))
              {
                Name = path + prefixSize;
                return true;
              }
              isOK = true;
              /* if "\\server\share" maps to root folder "d:\", there is no "." item.
                 But it's possible that there are another items */
            }
            {
              DWORD attrib = GetFileAttrib(path);
              if (isOK || attrib != INVALID_FILE_ATTRIBUTES && (attrib & FILE_ATTRIBUTE_DIRECTORY) != 0)
              {
                ClearBase();
                if (attrib != INVALID_FILE_ATTRIBUTES)
                  Attrib = attrib;
                else
                  SetAsDir();
                Name = path + prefixSize;
                return true;
              }
            }
            // ::SetLastError(lastError);
          }
        }
      }
  }
  #endif

  return finder.FindFirst(path, *this);
}
示例#15
0
	BOOL ShowApplet(HWND hWnd, LONG_PTR /*lData*/, LPCTSTR pstrCommand)
	{
		BOOL bWithFingerMenu = FALSE;
		CString szPath;
		CString szProgramFilesFolder;
		WCHAR szInstallDir[MAX_PATH];
		WCHAR szValue[MAX_PATH];
		ZeroMemory(szValue, sizeof(szValue));
		if (SHGetSpecialFolderPath(NULL, szValue, CSIDL_PROGRAM_FILES, FALSE))
		{
			szProgramFilesFolder.Format(L"%s", szValue);
		}
		if (RegistryGetString(HKEY_LOCAL_MACHINE, L"Software\\FingerMenu", L"InstallDir", szInstallDir, MAX_PATH) == S_OK)
		{
			szPath.Format(L"%s\\FingerMenu.exe", szInstallDir);
		}
		else
		{
			szPath = szProgramFilesFolder + L"\\FingerMenu\\FingerMenu.exe";
		}
		
		CFindFile finder; 
		if (finder.FindFile(szPath))
		{
			bWithFingerMenu = TRUE;
		}



		dlg1.SetTitle(L"Startup");
		dlg1.m_bWithFingerMenu = bWithFingerMenu;
		if (bWithFingerMenu)
		{
			dlg2.SetTitle(L"Menu options");
			dlg3.SetTitle(L"Menu exclusions");
			dlg7.SetTitle(L"Menu wnd exclusions");
		}
		dlg5.SetTitle(L"Msgbox options");
		dlg6.SetTitle(L"Msgbox exclusions");
		dlg8.SetTitle(L"Msgbox wnd exclusions");
		dlg4.SetTitle(L"Skins");
		dlg4.m_bWithFingerMenu = bWithFingerMenu;
		dlgAbout.SetTitle(L"About");

		// about box
		CString strCredits = "\n\n"
			    "\tFingerMenu v1.12\n\n"
				"\tFingerMsgBox v1.01\n\n"
				"\rdeveloped by:\n"
				"Francesco Carlucci\n"
				"<*****@*****.**>\n"
				"\n\n"
				"http://forum.xda-developers.com/\n"
				"                showthread.php?t=459125\n";

		dlgAbout.SetCredits(strCredits);

		CPropertySheet sheet;
		sheet.AddPage(dlg1);
		if (bWithFingerMenu)
		{
			sheet.AddPage(dlg2);
			sheet.AddPage(dlg3);
			sheet.AddPage(dlg7);
		}
		sheet.AddPage(dlg5);
		sheet.AddPage(dlg6);
		sheet.AddPage(dlg8);
		sheet.AddPage(dlg4);
		sheet.AddPage(dlgAbout);
		sheet.SetActivePage(_ttol(pstrCommand));
		if (IDOK == sheet.DoModal(hWnd))
		{
			ReloadConfiguration();
		}

		return TRUE;
	}