bool fs::rename(const std::string& from, const std::string& to) { const auto device = get_virtual_device(from); if (device != get_virtual_device(to)) { throw fmt::exception("fs::rename() between different devices not implemented.\nFrom: %s\nTo: %s", from, to); } if (device) { return device->rename(from, to); } #ifdef _WIN32 if (!MoveFileW(to_wchar(from).get(), to_wchar(to).get())) { g_tls_error = to_error(GetLastError()); return false; } return true; #else if (::rename(from.c_str(), to.c_str()) != 0) { g_tls_error = to_error(errno); return false; } return true; #endif }
FILE *ns_fopen(const char *path, const char *mode) { #ifdef _WIN32 wchar_t wpath[MAX_PATH_SIZE], wmode[10]; to_wchar(path, wpath, ARRAY_SIZE(wpath)); to_wchar(mode, wmode, ARRAY_SIZE(wmode)); return _wfopen(wpath, wmode); #else return fopen(path, mode); #endif }
bool fs::copy_file(const std::string& from, const std::string& to, bool overwrite) { #ifdef _WIN32 if (!CopyFileW(to_wchar(from).get(), to_wchar(to).get(), !overwrite)) #else if (OSCopyFile(from.c_str(), to.c_str(), overwrite)) #endif { LOG_WARNING(GENERAL, "Error copying '%s' to '%s': 0x%llx", from, to, GET_API_ERROR); return false; } return true; }
bool fs::rename(const std::string& from, const std::string& to) { #ifdef _WIN32 if (!MoveFileW(to_wchar(from).get(), to_wchar(to).get())) #else if (rename(from.c_str(), to.c_str())) #endif { LOG_WARNING(GENERAL, "Error renaming '%s' to '%s': 0x%llx", from, to, GET_API_ERROR); return false; } return true; }
bool fs::dir::open(const std::string& dirname) { if (m_dd != null) { #ifdef _WIN32 FindClose((HANDLE)m_dd); #else ::closedir((DIR*)m_dd); #endif } m_dd = null; m_path.reset(); if (!is_dir(dirname)) { return false; } #ifdef _WIN32 m_path = to_wchar(dirname + "/*"); #else m_path.reset(new char[dirname.size() + 1]); memcpy(m_path.get(), dirname.c_str(), dirname.size() + 1); #endif return true; }
bool fs::create_dir(const std::string& path) { if (auto device = get_virtual_device(path)) { return device->create_dir(path); } #ifdef _WIN32 if (!CreateDirectoryW(to_wchar(path).get(), NULL)) { g_tls_error = to_error(GetLastError()); return false; } return true; #else if (::mkdir(path.c_str(), S_IRWXU | S_IRGRP | S_IXGRP | S_IROTH | S_IXOTH) != 0) { g_tls_error = to_error(errno); return false; } return true; #endif }
bool fs::remove_dir(const std::string& path) { if (auto device = get_virtual_device(path)) { return device->remove_dir(path); } #ifdef _WIN32 if (!RemoveDirectoryW(to_wchar(path).get())) { g_tls_error = to_error(GetLastError()); return false; } return true; #else if (::rmdir(path.c_str()) != 0) { g_tls_error = to_error(errno); return false; } return true; #endif }
bool fs::stat(const std::string& path, stat_t& info) { g_tls_error = fse::ok; #ifdef _WIN32 WIN32_FILE_ATTRIBUTE_DATA attrs; if (!GetFileAttributesExW(to_wchar(path).get(), GetFileExInfoStandard, &attrs)) { return false; } info.is_directory = (attrs.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY) != 0; info.is_writable = (attrs.dwFileAttributes & FILE_ATTRIBUTE_READONLY) == 0; info.size = (u64)attrs.nFileSizeLow | ((u64)attrs.nFileSizeHigh << 32); info.atime = to_time_t(attrs.ftLastAccessTime); info.mtime = to_time_t(attrs.ftLastWriteTime); info.ctime = to_time_t(attrs.ftCreationTime); #else struct stat file_info; if (stat(path.c_str(), &file_info) < 0) { return false; } info.is_directory = S_ISDIR(file_info.st_mode); info.is_writable = file_info.st_mode & 0200; // HACK: approximation info.size = file_info.st_size; info.atime = file_info.st_atime; info.mtime = file_info.st_mtime; info.ctime = file_info.st_ctime; #endif return true; }
bool fs::exists(const std::string& path) { if (auto device = get_virtual_device(path)) { stat_t info; return device->stat(path, info); } #ifdef _WIN32 if (GetFileAttributesW(to_wchar(path).get()) == INVALID_FILE_ATTRIBUTES) { g_tls_error = to_error(GetLastError()); return false; } return true; #else struct ::stat file_info; if (::stat(path.c_str(), &file_info) != 0) { g_tls_error = to_error(errno); return false; } return true; #endif }
bool fs::remove_file(const std::string& path) { if (auto device = get_virtual_device(path)) { return device->remove(path); } #ifdef _WIN32 if (!DeleteFileW(to_wchar(path).get())) { g_tls_error = to_error(GetLastError()); return false; } return true; #else if (::unlink(path.c_str()) != 0) { g_tls_error = to_error(errno); return false; } return true; #endif }
int mg_open(const char *path, int flag, int mode) { /* LCOV_EXCL_LINE */ #if defined(_WIN32) && !defined(WINCE) wchar_t wpath[MG_MAX_PATH]; to_wchar(path, wpath, ARRAY_SIZE(wpath)); return _wopen(wpath, flag, mode); #else return open(path, flag, mode); /* LCOV_EXCL_LINE */ #endif }
bool fs::exists(const std::string& path) { #ifdef _WIN32 return GetFileAttributesW(to_wchar(path).get()) != 0xFFFFFFFF; #else struct stat buffer; return stat(path.c_str(), &buffer) == 0; #endif }
int ns_open(const char *path, int flag, int mode) { /* LCOV_EXCL_LINE */ #ifdef _WIN32 wchar_t wpath[MAX_PATH_SIZE]; to_wchar(path, wpath, ARRAY_SIZE(wpath)); return _wopen(wpath, flag, mode); #else return open(path, flag, mode); /* LCOV_EXCL_LINE */ #endif }
int ns_stat(const char *path, ns_stat_t *st) { #ifdef _WIN32 wchar_t wpath[MAX_PATH_SIZE]; to_wchar(path, wpath, ARRAY_SIZE(wpath)); DBG(("[%ls] -> %d", wpath, _wstati64(wpath, st))); return _wstati64(wpath, st); #else return stat(path, st); #endif }
bool fs::dir::read(std::string& name, stat_t& info) { g_tls_error = fse::ok; if (!m_path) { return false; } #ifdef _WIN32 WIN32_FIND_DATAW found; if (m_dd == -1) { m_dd = (std::intptr_t)FindFirstFileW(to_wchar(m_path.get() + "/*"s).get(), &found); if (m_dd == -1) { return false; } } else if (!FindNextFileW((HANDLE)m_dd, &found)) { return false; } to_utf8(name, found.cFileName); info.is_directory = (found.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY) != 0; info.is_writable = (found.dwFileAttributes & FILE_ATTRIBUTE_READONLY) == 0; info.size = ((u64)found.nFileSizeHigh << 32) | (u64)found.nFileSizeLow; info.atime = to_time_t(found.ftLastAccessTime); info.mtime = to_time_t(found.ftLastWriteTime); info.ctime = to_time_t(found.ftCreationTime); #else const auto found = ::readdir((DIR*)m_dd); struct stat file_info; if (!found || ::fstatat(::dirfd((DIR*)m_dd), found->d_name, &file_info, 0) < 0) { return false; } name = found->d_name; info.is_directory = S_ISDIR(file_info.st_mode); info.is_writable = file_info.st_mode & 0200; // HACK: approximation info.size = file_info.st_size; info.atime = file_info.st_atime; info.mtime = file_info.st_mtime; info.ctime = file_info.st_ctime; #endif return true; }
int CMainToolBar::GetSearchKey(std::wstring& strText) { if( m_hwndSearchBox ){ int nBufferSize = ::GetWindowTextLength( m_hwndSearchBox ) + 1; std::vector<TCHAR> vText(nBufferSize); ::GetWindowText( m_hwndSearchBox, &vText[0], vText.size() ); strText = to_wchar(&vText[0]); }else{ strText = L""; } return strText.length(); }
bool fs::create_dir(const std::string& dir) { #ifdef _WIN32 if (!CreateDirectoryW(to_wchar(dir).get(), NULL)) #else if (mkdir(dir.c_str(), 0777)) #endif { LOG_WARNING(GENERAL, "Error creating directory '%s': 0x%llx", dir, GET_API_ERROR); return false; } return true; }
bool fs::remove_dir(const std::string& dir) { #ifdef _WIN32 if (!RemoveDirectoryW(to_wchar(dir).get())) #else if (rmdir(dir.c_str())) #endif { LOG_WARNING(GENERAL, "Error deleting directory '%s': 0x%llx", dir, GET_API_ERROR); return false; } return true; }
bool fs::remove_file(const std::string& file) { #ifdef _WIN32 if (!DeleteFileW(to_wchar(file).get())) #else if (unlink(file.c_str())) #endif { LOG_WARNING(GENERAL, "Error deleting file '%s': 0x%llx", file, GET_API_ERROR); return false; } return true; }
/* 外部ヘルプ1 @date 2012.09.26 Moca HTMLHELP対応 */ void CViewCommander::Command_EXTHELP1( void ) { retry:; if( CHelpManager().ExtWinHelpIsSet( &(GetDocument()->m_cDocType.GetDocumentAttribute()) ) == false){ // if( 0 == wcslen( GetDllShareData().m_Common.m_szExtHelp1 ) ){ ErrorBeep(); //From Here Sept. 15, 2000 JEPRO // [Esc]キーと[x]ボタンでも中止できるように変更 if( IDYES == ::MYMESSAGEBOX( NULL, MB_YESNOCANCEL | MB_ICONEXCLAMATION | MB_APPLMODAL | MB_TOPMOST, GSTR_APPNAME, //To Here Sept. 15, 2000 LS(STR_ERR_CEDITVIEW_CMD01) ) ){ /* 共通設定 プロパティシート */ if( !CEditApp::getInstance()->OpenPropertySheet( ID_PROPCOM_PAGENUM_HELPER ) ){ return; } goto retry; } // Jun. 15, 2000 genta else{ return; } } CNativeW cmemCurText; const TCHAR* helpfile = CHelpManager().GetExtWinHelp( &(GetDocument()->m_cDocType.GetDocumentAttribute()) ); /* 現在カーソル位置単語または選択範囲より検索等のキーを取得 */ m_pCommanderView->GetCurrentTextForSearch( cmemCurText, false ); TCHAR path[_MAX_PATH]; if( _IS_REL_PATH( helpfile ) ){ // 2003.06.23 Moca 相対パスは実行ファイルからのパス // 2007.05.21 ryoji 相対パスは設定ファイルからのパスを優先 GetInidirOrExedir( path, helpfile ); }else{ auto_strcpy( path, helpfile ); } // 2012.09.26 Moca HTMLHELP対応 TCHAR szExt[_MAX_EXT]; _tsplitpath( path, NULL, NULL, NULL, szExt ); if( 0 == _tcsicmp(szExt, _T(".chi")) || 0 == _tcsicmp(szExt, _T(".chm")) || 0 == _tcsicmp(szExt, _T(".col")) ){ std::wstring pathw = to_wchar(path); Command_EXTHTMLHELP( pathw.c_str(), cmemCurText.GetStringPtr() ); }else{ ::WinHelp( m_pCommanderView->m_hwndParent, path, HELP_KEY, (ULONG_PTR)cmemCurText.GetStringPtr() ); } return; }
bool fs::is_file(const std::string& path) { if (auto device = get_virtual_device(path)) { stat_t info; if (!device->stat(path, info)) { return false; } if (info.is_directory) { g_tls_error = error::exist; return false; } return true; } #ifdef _WIN32 const DWORD attrs = GetFileAttributesW(to_wchar(path).get()); if (attrs == INVALID_FILE_ATTRIBUTES) { g_tls_error = to_error(GetLastError()); return false; } #else struct ::stat file_info; if (::stat(path.c_str(), &file_info) != 0) { g_tls_error = to_error(errno); return false; } #endif // TODO: correct file type check #ifdef _WIN32 if ((attrs & FILE_ATTRIBUTE_DIRECTORY) != 0) #else if (S_ISDIR(file_info.st_mode)) #endif { g_tls_error = error::exist; return false; } return true; }
void fs::dir::import(handle_type dd, const std::string& path) { if (m_dd != null) { #ifdef _WIN32 FindClose((HANDLE)m_dd); #else ::closedir((DIR*)m_dd); #endif } m_dd = dd; #ifdef _WIN32 m_path = to_wchar(path); #else m_path.reset(new char[path.size() + 1]); memcpy(m_path.get(), path.c_str(), path.size() + 1); #endif }
bool fs::is_dir(const std::string& dir) { #ifdef _WIN32 DWORD attrs; if ((attrs = GetFileAttributesW(to_wchar(dir).get())) == INVALID_FILE_ATTRIBUTES) { return false; } return (attrs & FILE_ATTRIBUTE_DIRECTORY) != 0; #else struct stat file_info; if (stat(dir.c_str(), &file_info) < 0) { return false; } return S_ISDIR(file_info.st_mode); #endif }
bool fs::truncate_file(const std::string& path, u64 length) { if (auto device = get_virtual_device(path)) { return device->trunc(path, length); } #ifdef _WIN32 // Open the file const auto handle = CreateFileW(to_wchar(path).get(), GENERIC_WRITE, FILE_SHARE_READ, NULL, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, NULL); if (handle == INVALID_HANDLE_VALUE) { g_tls_error = to_error(GetLastError()); return false; } LARGE_INTEGER distance; distance.QuadPart = length; // Seek and truncate if (!SetFilePointerEx(handle, distance, NULL, FILE_BEGIN) || !SetEndOfFile(handle)) { g_tls_error = to_error(GetLastError()); CloseHandle(handle); return false; } CloseHandle(handle); return true; #else if (::truncate(path.c_str(), length) != 0) { g_tls_error = to_error(errno); return false; } return true; #endif }
bool fs::is_file(const std::string& file) { g_tls_error = fse::ok; #ifdef _WIN32 DWORD attrs; if ((attrs = GetFileAttributesW(to_wchar(file).get())) == INVALID_FILE_ATTRIBUTES) { return false; } return (attrs & FILE_ATTRIBUTE_DIRECTORY) == 0; #else struct stat file_info; if (stat(file.c_str(), &file_info) < 0) { return false; } return !S_ISDIR(file_info.st_mode); #endif }
DIR *opendir(const char *name) { DIR *dir = NULL; wchar_t wpath[MAX_PATH]; DWORD attrs; if (name == NULL) { SetLastError(ERROR_BAD_ARGUMENTS); } else if ((dir = (DIR *) MG_MALLOC(sizeof(*dir))) == NULL) { SetLastError(ERROR_NOT_ENOUGH_MEMORY); } else { to_wchar(name, wpath, ARRAY_SIZE(wpath)); attrs = GetFileAttributesW(wpath); if (attrs != 0xFFFFFFFF && (attrs & FILE_ATTRIBUTE_DIRECTORY)) { (void) wcscat(wpath, L"\\*"); dir->handle = FindFirstFileW(wpath, &dir->info); dir->result.d_name[0] = '\0'; } else { MG_FREE(dir); dir = NULL; } } return dir; }
bool truncate_file(const std::string& file, u64 length) { // open the file const auto handle = CreateFileW(to_wchar(file).get(), GENERIC_WRITE, FILE_SHARE_READ, NULL, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, NULL); if (handle == INVALID_HANDLE_VALUE) { return false; } LARGE_INTEGER distance; distance.QuadPart = length; // seek and truncate if (!SetFilePointerEx(handle, distance, NULL, FILE_BEGIN) || !SetEndOfFile(handle)) { const auto error = GetLastError(); CloseHandle(handle); SetLastError(error); return false; } return CloseHandle(handle); }
void conversion_big_c(void) { to_wchar(arg_get_wchar()); }
/*! @return 機能が割り当てられているキーストロークの数 @date Oct. 31, 2001 genta 動的な機能名に対応するため引数追加 @date 2007.02.22 ryoji デフォルト機能割り当てに関する処理を追加 */ int CKeyBind::CreateKeyBindList( HINSTANCE hInstance, //!< [in] インスタンスハンドル int nKeyNameArrNum, //!< [in] KEYDATA* pKeyNameArr, //!< [out] CNativeW& cMemList, //!< CFuncLookup* pcFuncLookup, //!< [in] 機能番号→名前の対応を取る BOOL bGetDefFuncCode //!< [in] ON:デフォルト機能割り当てを使う/OFF:使わない デフォルト:TRUE ) { int i; int j; int nValidKeys; WCHAR pszStr[256]; WCHAR szFuncName[256]; WCHAR szFuncNameJapanese[256]; nValidKeys = 0; cMemList.SetString(LTEXT("")); const WCHAR* pszSHIFT = LTEXT("Shift+"); const WCHAR* pszCTRL = LTEXT("Ctrl+"); const WCHAR* pszALT = LTEXT("Alt+"); const WCHAR* pszTAB = LTEXT("\t"); const WCHAR* pszCR = LTEXT("\r\n"); //\r=0x0d=CRを追加 cMemList.AppendString( LSW(STR_ERR_DLGKEYBIND1) ); cMemList.AppendString( pszCR ); cMemList.AppendString( LTEXT("-----\t-----\t-----\t-----\t-----") ); cMemList.AppendString( pszCR ); for( j = 0; j < 8; ++j ){ for( i = 0; i < nKeyNameArrNum; ++i ){ int iFunc = GetFuncCodeAt( pKeyNameArr[i], j, bGetDefFuncCode ); if( 0 != iFunc ){ nValidKeys++; if( j & _SHIFT ){ cMemList.AppendString( pszSHIFT ); } if( j & _CTRL ){ cMemList.AppendString( pszCTRL ); } if( j & _ALT ){ cMemList.AppendString( pszALT ); } cMemList.AppendString( to_wchar(pKeyNameArr[i].m_szKeyName) ); // Oct. 31, 2001 genta if( !pcFuncLookup->Funccode2Name( iFunc, szFuncNameJapanese, 255 )){ auto_strcpy( szFuncNameJapanese, LSW(STR_ERR_DLGKEYBIND2) ); } szFuncName[0] = LTEXT('\0'); /*"---unknown()--"*/ // /* 機能名日本語 */ // ::LoadString( // hInstance, // pKeyNameArr[i].m_nFuncCodeArr[j], // szFuncNameJapanese, 255 // ); cMemList.AppendString( pszTAB ); cMemList.AppendString( szFuncNameJapanese ); /* 機能ID→関数名,機能名日本語 */ //@@@ 2002.2.2 YAZAKI マクロをCSMacroMgrに統一 CSMacroMgr::GetFuncInfoByID( hInstance, iFunc, szFuncName, szFuncNameJapanese ); /* 関数名 */ cMemList.AppendString( pszTAB ); cMemList.AppendString( szFuncName ); /* 機能番号 */ cMemList.AppendString( pszTAB ); auto_sprintf( pszStr, LTEXT("%d"), iFunc ); cMemList.AppendString( pszStr ); /* キーマクロに記録可能な機能かどうかを調べる */ cMemList.AppendString( pszTAB ); //@@@ 2002.2.2 YAZAKI マクロをCSMacroMgrに統一 if( CSMacroMgr::CanFuncIsKeyMacro( iFunc ) ){ cMemList.AppendString( LTEXT("○") ); }else{ cMemList.AppendString( LTEXT("×") ); } cMemList.AppendString( pszCR ); } } } return nValidKeys; }
/* TRUE==正常 FALSE==入力エラー */ int CDlgGrep::GetData( void ) { /* サブフォルダからも検索する*/ m_bSubFolder = ::IsDlgButtonChecked( GetHwnd(), IDC_CHK_SUBFOLDER ); m_pShareData->m_Common.m_sSearch.m_bGrepSubFolder = m_bSubFolder; /* Grep:サブフォルダも検索 */ /* この編集中のテキストから検索する */ m_bFromThisText = ::IsDlgButtonChecked( GetHwnd(), IDC_CHK_FROMTHISTEXT ); /* 英大文字と英小文字を区別する */ m_sSearchOption.bLoHiCase = (0!=::IsDlgButtonChecked( GetHwnd(), IDC_CHK_LOHICASE )); //2001/06/23 N.Nakatani /* 単語単位で検索 */ m_sSearchOption.bWordOnly = (0!=::IsDlgButtonChecked( GetHwnd(), IDC_CHK_WORD )); /* 正規表現 */ m_sSearchOption.bRegularExp = (0!=::IsDlgButtonChecked( GetHwnd(), IDC_CHK_REGULAREXP )); /* 文字コード自動判別 */ // m_bKanjiCode_AutoDetect = ::IsDlgButtonChecked( GetHwnd(), IDC_CHK_KANJICODEAUTODETECT ); /* 文字コードセット */ { int nIdx; HWND hWndCombo = ::GetDlgItem( GetHwnd(), IDC_COMBO_CHARSET ); nIdx = Combo_GetCurSel( hWndCombo ); m_nGrepCharSet = (ECodeType)Combo_GetItemData( hWndCombo, nIdx ); } /* 行を出力/該当部分/否マッチ行 を出力 */ if( ::IsDlgButtonChecked( GetHwnd(), IDC_RADIO_OUTPUTLINE ) ){ m_nGrepOutputLineType = 1; }else if( ::IsDlgButtonChecked( GetHwnd(), IDC_RADIO_NOHIT ) ){ m_nGrepOutputLineType = 2; }else{ m_nGrepOutputLineType = 0; } /* Grep: 出力形式 */ if( FALSE != ::IsDlgButtonChecked( GetHwnd(), IDC_RADIO_OUTPUTSTYLE1 ) ){ m_nGrepOutputStyle = 1; /* Grep: 出力形式 */ } if( FALSE != ::IsDlgButtonChecked( GetHwnd(), IDC_RADIO_OUTPUTSTYLE2 ) ){ m_nGrepOutputStyle = 2; /* Grep: 出力形式 */ } if( FALSE != ::IsDlgButtonChecked( GetHwnd(), IDC_RADIO_OUTPUTSTYLE3 ) ){ m_nGrepOutputStyle = 3; } m_bGrepOutputFileOnly = IsDlgButtonCheckedBool( GetHwnd(), IDC_CHECK_FILE_ONLY ); m_bGrepOutputBaseFolder = IsDlgButtonCheckedBool( GetHwnd(), IDC_CHECK_BASE_PATH ); m_bGrepSeparateFolder = IsDlgButtonCheckedBool( GetHwnd(), IDC_CHECK_SEP_FOLDER ); /* 検索文字列 */ int nBufferSize = ::GetWindowTextLength( GetItemHwnd(IDC_COMBO_TEXT) ) + 1; std::vector<TCHAR> vText(nBufferSize); ::DlgItem_GetText( GetHwnd(), IDC_COMBO_TEXT, &vText[0], nBufferSize); m_strText = to_wchar(&vText[0]); m_bSetText = true; /* 検索ファイル */ ::DlgItem_GetText( GetHwnd(), IDC_COMBO_FILE, m_szFile, _countof2(m_szFile) ); /* 検索フォルダ */ ::DlgItem_GetText( GetHwnd(), IDC_COMBO_FOLDER, m_szFolder, _countof2(m_szFolder) ); m_pShareData->m_Common.m_sSearch.m_nGrepCharSet = m_nGrepCharSet; // 文字コード自動判別 m_pShareData->m_Common.m_sSearch.m_nGrepOutputLineType = m_nGrepOutputLineType; // 行を出力/該当部分/否マッチ行 を出力 m_pShareData->m_Common.m_sSearch.m_nGrepOutputStyle = m_nGrepOutputStyle; // Grep: 出力形式 m_pShareData->m_Common.m_sSearch.m_bGrepOutputFileOnly = m_bGrepOutputFileOnly; m_pShareData->m_Common.m_sSearch.m_bGrepOutputBaseFolder = m_bGrepOutputBaseFolder; m_pShareData->m_Common.m_sSearch.m_bGrepSeparateFolder = m_bGrepSeparateFolder; //やめました // if( 0 == wcslen( m_szText ) ){ // WarningMessage( GetHwnd(), _T("検索のキーワードを指定してください。") ); // return FALSE; // } if( 0 != auto_strlen( m_szFile ) ){ CGrepEnumKeys enumKeys; int nErrorNo = enumKeys.SetFileKeys( m_szFile ); if( 1 == nErrorNo ){ WarningMessage( GetHwnd(), LS(STR_DLGGREP2) ); return FALSE; }else if( nErrorNo == 2 ){ WarningMessage( GetHwnd(), LS(STR_DLGGREP3) ); return FALSE; } } /* この編集中のテキストから検索する */ if( m_szFile[0] == _T('\0') ){ // Jun. 16, 2003 Moca // 検索パターンが指定されていない場合のメッセージ表示をやめ、 // 「*.*」が指定されたものと見なす. _tcscpy( m_szFile, _T("*.*") ); } if( m_szFolder[0] == _T('\0') ){ WarningMessage( GetHwnd(), LS(STR_DLGGREP4) ); return FALSE; } { //カレントディレクトリを保存。このブロックから抜けるときに自動でカレントディレクトリは復元される。 CCurrentDirectoryBackupPoint cCurDirBackup; // 2011.11.24 Moca 複数フォルダ指定 std::vector<std::tstring> vPaths; CGrepAgent::CreateFolders( m_szFolder, vPaths ); int nFolderLen = 0; TCHAR szFolder[_MAX_PATH]; szFolder[0] = _T('\0'); for( int i = 0 ; i < (int)vPaths.size(); i ++ ){ // 相対パス→絶対パス if( !::SetCurrentDirectory( vPaths[i].c_str() ) ){ WarningMessage( GetHwnd(), LS(STR_DLGGREP5) ); return FALSE; } TCHAR szFolderItem[_MAX_PATH]; ::GetCurrentDirectory( _MAX_PATH, szFolderItem ); // ;がフォルダ名に含まれていたら""で囲う if( auto_strchr( szFolderItem, _T(';') ) ){ szFolderItem[0] = _T('"'); ::GetCurrentDirectory( _MAX_PATH, szFolderItem + 1 ); auto_strcat(szFolderItem, _T("\"")); } int nFolderItemLen = auto_strlen( szFolderItem ); if( _MAX_PATH < nFolderLen + nFolderItemLen + 1 ){ WarningMessage( GetHwnd(), LS(STR_DLGGREP6) ); return FALSE; } if( i ){ auto_strcat( szFolder, _T(";") ); } auto_strcat( szFolder, szFolderItem ); nFolderLen = auto_strlen( szFolder ); } auto_strcpy( m_szFolder, szFolder ); } //@@@ 2002.2.2 YAZAKI CShareData.AddToSearchKeyArr()追加に伴う変更 /* 検索文字列 */ if( 0 < m_strText.size() ){ // From Here Jun. 26, 2001 genta // 正規表現ライブラリの差し替えに伴う処理の見直し int nFlag = 0; nFlag |= m_sSearchOption.bLoHiCase ? 0x01 : 0x00; if( m_sSearchOption.bRegularExp && !CheckRegexpSyntax( m_strText.c_str(), GetHwnd(), true, nFlag) ){ return FALSE; } // To Here Jun. 26, 2001 genta 正規表現ライブラリ差し替え if( m_strText.size() < _MAX_PATH ){ CSearchKeywordManager().AddToSearchKeyArr( m_strText.c_str() ); m_pShareData->m_Common.m_sSearch.m_sSearchOption = m_sSearchOption; // 検索オプション } }else{ // 2014.07.01 空キーも登録する CSearchKeywordManager().AddToSearchKeyArr( L"" ); } // この編集中のテキストから検索する場合、履歴に残さない Uchi 2008/5/23 if (!m_bFromThisText) { /* 検索ファイル */ CSearchKeywordManager().AddToGrepFileArr( m_szFile ); /* 検索フォルダ */ CSearchKeywordManager().AddToGrepFolderArr( m_szFolder ); } return TRUE; }