BOOL VeryfyIniConfig(const WnpdInfo& info) { wstring strPath; vector<wstring> strFileList; strPath = info.nginx_path + L"\\" + info.nginx_exe_filename; if(!CheckFileExist(strPath)) { strFileList.push_back(strPath); } strPath = info.nginx_conf_file; if(!CheckFileExist(strPath)) { strFileList.push_back(strPath); } strPath = info.php_cgi_path + L"\\" +info.php_cgi_exe_filename; if(!CheckFileExist(strPath)) { strFileList.push_back(strPath); } if(strFileList.size()>0) { HandleFileError(strFileList); } return strFileList.size() == 0; }
/* * メール送信スレッド */ DWORD WINAPI SendMailThread(LPVOID lpParam) { MAILDATA mdat; HWND hDlg; char attach_filepath[MAX_PATH]; BOOL attach_exist; int mailbody_len; /*本文の長さ*/ int subject_len; /*件名の長さ*/ hDlg = (HWND)lpParam; if(CheckInputData(hDlg) != TRUE){ return 0; } InitMailData(&mdat); GetDlgItemText(hDlg,IDC_SENDER,mdat.sender,sizeof(mdat.sender)); GetDlgItemText(hDlg,IDC_MAILFROM,mdat.from,sizeof(mdat.from)); GetDlgItemText(hDlg,IDC_MAILTO,mdat.to,sizeof(mdat.to)); GetDlgItemText(hDlg,IDC_MAILPRIORITY,mdat.priority,sizeof(mdat.priority)); GetDlgItemText(hDlg,IDC_PCNAME,mdat.pc_name,sizeof(mdat.pc_name)); strcpy(mdat.mailer,"SMILE MAILER"); strcpy(mdat.reply,mdat.from); /*添付ファイルを読み込む、*/ GetDlgItemText(hDlg,IDC_ATTACHFILENAME,attach_filepath,sizeof(attach_filepath)); attach_exist = CheckFileExist(attach_filepath); if(attach_exist == TRUE){ /*関数内部でメモリを割り当てるので、必ず後で解放すること。*/ if(ReadAttachFile(attach_filepath,&mdat) == FALSE){ StringTableSendMessageBeep(hDlg,WM_SENDMAIL, IDS_ERROR_READ_ATTACH_FILE,MB_ICONEXCLAMATION); } } /*本文をダイアログボックスから読み込む、解放を忘れずに*/ mailbody_len = GetWindowTextLength(GetDlgItem(hDlg,IDC_MAILBODY)); mdat.body = (char *)GlobalAlloc(GMEM_FIXED,mailbody_len + 1); GetDlgItemText(hDlg,IDC_MAILBODY,mdat.body,mailbody_len + 1); /*件名をダイアログボックスから読み込む、解放を忘れずに*/ subject_len = GetWindowTextLength(GetDlgItem(hDlg,IDC_MAILSUBJECT)); mdat.subject = (char *)GlobalAlloc(GMEM_FIXED,subject_len + 1); GetDlgItemText(hDlg,IDC_MAILSUBJECT,mdat.subject,subject_len + 1); GetMXAndSendMail(hDlg,&mdat,attach_exist); GlobalFree(mdat.attach); GlobalFree(mdat.body); GlobalFree(mdat.subject); return 0; }
BOOL CFolderCompare::ProcessFile( LPCTSTR strFileName ) { if (FALSE == CheckFileExist(strFileName)) { return WriteFile(strFileName, m_hResultFile); } CMyPath myPath; CString strOldFileName = myPath.TransferSourcePath(m_strNewSource, m_strOldSource, strFileName); if (FALSE == CheckSum(strFileName, strOldFileName)) { return WriteFile(strFileName, m_hTempFile); } return TRUE; }
//============================================================================================= // Рекурсивно проходим по каталогу WebClient и по его подкаталогам //============================================================================================= void TFolderCheck::GetFileList(LPTSTR sPath, LPTSTR sExt, LPTSTR sEXT) { WIN32_FIND_DATA pFILEDATA; HANDLE hFile = FindFirstFile(strcat(sPath,"\\*.*"),&pFILEDATA); sPath[strlen(sPath) - strlen(strstr(sPath,"*.*"))] = '\0'; if (hFile!=INVALID_HANDLE_VALUE) { char * chBuf; do { if (strlen(pFILEDATA.cFileName) == 1 && strchr(pFILEDATA.cFileName,'.') !=NULL) if (FindNextFile(hFile,&pFILEDATA) == 0) break; if (strlen(pFILEDATA.cFileName) == 2 && strstr(pFILEDATA.cFileName,"..") !=NULL) if(FindNextFile(hFile,&pFILEDATA) == 0) break; //Если нашли директорию, запускаем в ней рекурсивный поиск if(pFILEDATA.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY) { //если папка не является исключением из списка GetFileList(strcat(sPath,pFILEDATA.cFileName), sExt, sEXT); //Log->Write(AnsiString(sPath)); //else Log->Write("================= "+AnsiString(sPath)+" execution ============================= "); // GetFileList(strcat(sPath,pFILEDATA.cFileName), sExt, sEXT); //Востанавливаем длину пути sPath[strlen(sPath) - strlen(pFILEDATA.cFileName)-1] = '\0'; Application->ProcessMessages(); } else { //Проверяем на соотвествие sExt расширения pFILEDATA.cFileName //Log->Write(AnsiString(sPath)+AnsiString(pFILEDATA.cFileName)); CheckFileExist(sPath, pFILEDATA.cFileName); } } while (FindNextFile(hFile,&pFILEDATA)); } }
void MapCreater::NewArea(STRARR& cmd) { if (cmd.size()>1) { if(!CheckDirExist(cmd[0])) NewMap(STRARR(cmd.begin(), cmd.begin()+1)); string mappath = _working_dir + "/" + cmd[0]; ConfigFile mapdata(mappath + MAPDATA); mapdata.Add(string("area_") + cmd[1], cmd[1]); string areapath = mappath + "/" + cmd[1]; CheckFileExist(areapath + AREADATA); cout<<"Area ["<<cmd[1]<<"] created in ["<<cmd[0]<<"]\n"; } else cout<<"newarea (mapname) (areaname)\n"; }
bool CConverToMK::InitialiseHelp() { if (!CheckFileExist(m_pszHelpFile)) { return false; } ifstream kInStream(m_pszHelpFile); if (!kInStream.is_open()) { return false; } char szTempData[1024] = {0}; while (kInStream.getline(szTempData,1024)) { string strData = szTempData; m_kHelpData.push_back(strData); } return true; }
bool CConverToMK::ProcessPath(const char* pszVCPath, const char* pszPath, string& strRes ) { if (0 == pszPath || !*pszPath) { return false; } if (strRes.size()) { strRes = ""; } filesystem::path kVCFile(pszVCPath); filesystem::path kMKFile(m_pszMKFile); filesystem::path kInputPath(pszPath); unsigned int uiParentFolderCount = 0; string strFilename = kInputPath.filename().string(); kInputPath = kInputPath.parent_path(); kVCFile = kVCFile.parent_path(); kMKFile = kMKFile.parent_path(); StringVector kVCSets; StringVector kMKSets; StringVector kTargetSets; StringVector kTempVC; BOOST_AUTO(pkInputPathPos,kInputPath.begin()); BOOST_AUTO(pkVCPos,kVCFile.begin()); BOOST_AUTO(pkMKPos,kMKFile.begin()); while (pkInputPathPos != kInputPath.end()) { string strPath = pkInputPathPos->string().c_str(); if (strcmp(strPath.c_str(),"..") == 0) { uiParentFolderCount++; pkInputPathPos++; continue; } kTargetSets.push_back(strPath); pkInputPathPos++; } while (pkVCPos != kVCFile.end()) { filesystem::path strVC = *pkVCPos; kVCSets.push_back(strVC.string()); pkVCPos++; } kTempVC = kVCSets; while (0 < uiParentFolderCount) { kTempVC.pop_back(); kVCSets.pop_back(); uiParentFolderCount--; } while (pkMKPos != kMKFile.end()) { string strVC = pkMKPos->string(); kMKSets.push_back(strVC); pkMKPos++; } unsigned int uiMin = kMKSets.size() < kVCSets.size() ? kMKSets.size() : kVCSets.size(); unsigned int uiIndex = 0; for (uiIndex = 0;uiIndex < uiMin;uiIndex++) { if (strcmp(kMKSets[uiIndex].c_str(),kVCSets[uiIndex].c_str()) != 0) { break; } } kMKSets.erase(kMKSets.begin(),kMKSets.begin() + uiIndex); kVCSets.erase(kVCSets.begin(),kVCSets.begin() + uiIndex); strRes += "."; string strPrePath = ""; for (unsigned int uiIndex = 0;uiIndex < kTempVC.size();uiIndex++) { strPrePath += kTempVC[uiIndex]; strPrePath += "\\"; } for (unsigned int uiIndex = 0;uiIndex < kVCSets.size();uiIndex++) { strRes += "\\"; strRes += kVCSets[uiIndex]; } for (unsigned int uiIndex = 0;uiIndex < kTargetSets.size();uiIndex++) { strRes += "\\"; strPrePath += kTargetSets[uiIndex]; strPrePath += "\\"; strRes += kTargetSets[uiIndex]; } strRes += "\\"; strRes += strFilename; strPrePath += strFilename; if (!CheckFileExist(strPrePath.c_str())) { return false; } return true; }
bool CConverToMK::ParseMKFile() { if (!CheckFileExist(m_pszMKFile)) { return false; } ifstream kInStream(m_pszMKFile); if (!kInStream.is_open()) { return false; } char szTempData[1024] = {0}; while (kInStream.getline(szTempData,1024)) { string strData = szTempData; m_kMKFileData.push_back(strData); } unsigned int uiEndPosition = -1; StringVector::iterator pkIterator = m_kMKFileData.begin(); StringVector::iterator pkEndIterator = m_kMKFileData.begin(); for (unsigned int i = 0;i < m_kMKFileData.size();i++) { iterator_range<string::iterator> kRange; kRange = find_first(m_kMKFileData[i],"LOCAL_SRC_FILES"); if (kRange.size() != 0) { m_uiKeyStringPosition = i; break; } pkIterator++; } pkEndIterator = pkIterator; for (unsigned int i = m_uiKeyStringPosition;i < m_kMKFileData.size();i++) { iterator_range<string::iterator> kRange; kRange = find_first(m_kMKFileData[i],"\\"); string strTemp; strTemp = m_kMKFileData[i]; pkEndIterator++; if (kRange.size() == 0) { if (strTemp.length() == 0) { continue; } uiEndPosition = i; break; } if (m_uiKeyStringPosition == i) { continue; } } m_kMKFileData.erase(pkIterator,pkEndIterator); kInStream.close(); return true; }