static bool DLLExists(const wxString& DLLName) { wxStandardPathsBase& StdPaths = wxStandardPaths::Get(); if (wxFileExists(StdPaths.GetExecutablePath().BeforeLast(PATHSEPCH) + PATHSEPSTR + DLLName)) return true; if (wxFileExists(StdPaths.GetExecutablePath().BeforeLast(PATHSEPCH) + PATHSEPSTR + ".." + PATHSEPSTR + DLLName)) return true; if (wxFileExists(wxGetOSDirectory() + PATHSEPSTR + DLLName)) return true; if (wxFileExists(wxGetOSDirectory() + PATHSEPSTR + "system32" + PATHSEPSTR + DLLName)) return true; return false; }
AutoDetectResult CompilerGDC::AutoDetectInstallationDir() { wxString sep = wxFileName::GetPathSeparator(); if (platform::windows) { // look first if MinGW was installed with Code::Blocks (new in beta6) m_MasterPath = ConfigManager::GetExecutableFolder(); if (!wxFileExists(m_MasterPath + sep + _T("bin") + sep + m_Programs.C)) { // no... search for MinGW installation dir wxString windir = wxGetOSDirectory(); wxFileConfig ini(_T(""), _T(""), windir + _T("/MinGW.ini"), _T(""), wxCONFIG_USE_LOCAL_FILE | wxCONFIG_USE_NO_ESCAPE_CHARACTERS); m_MasterPath = ini.Read(_T("/InstallSettings/InstallPath"), _T("C:\\MinGW")); if (!wxFileExists(m_MasterPath + sep + _T("bin") + sep + m_Programs.C)) { #ifdef __WXMSW__ // for wxRegKey // not found... // look for dev-cpp installation wxRegKey key; // defaults to HKCR key.SetName(_T("HKEY_LOCAL_MACHINE\\Software\\Dev-C++")); if (key.Exists() && key.Open(wxRegKey::Read)) { // found; read it key.QueryValue(_T("Install_Dir"), m_MasterPath); } else { // installed by inno-setup // HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\Minimalist GNU for Windows 4.1_is1 wxString name; long index; key.SetName(_T("HKEY_LOCAL_MACHINE\\SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Uninstall")); //key.SetName("HKEY_LOCAL_MACHINE\\SOFTWARE\\Microsoft\\Windows\\CurrentVersion"); bool ok = key.GetFirstKey(name, index); while (ok && !name.StartsWith(_T("Minimalist GNU for Windows"))) { ok = key.GetNextKey(name, index); } if (ok) { name = key.GetName() + _T("\\") + name; key.SetName(name); Manager::Get()->GetLogManager()->DebugLog(F(_T("name: %s"), name.wx_str())); if (key.Exists()) key.QueryValue(_T("InstallLocation"), m_MasterPath); } } #endif } } else m_Programs.MAKE = _T("make.exe"); // we distribute "make" not "mingw32-make" } else m_MasterPath = _T("/usr"); AutoDetectResult ret = wxFileExists(m_MasterPath + sep + _T("bin") + sep + m_Programs.C) ? adrDetected : adrGuessed; if (ret == adrDetected) { AddIncludeDir(m_MasterPath + sep + _T("include") + sep + _T("d")); AddLibDir(m_MasterPath + sep + _T("lib")); } return ret; }
/////////// // Collect void FontsCollectorThread::Collect() { // Make sure there is a separator at the end destination += _T("\\"); // Reset log box wxTextCtrl *LogBox = collector->LogBox; wxMutexGuiEnter(); LogBox->SetValue(_T("")); LogBox->SetDefaultStyle(wxTextAttr(wxColour(0,0,180))); LogBox->AppendText(_("Searching for fonts in file...\n")); LogBox->SetDefaultStyle(wxTextAttr(wxColour(0,0,0))); LogBox->Refresh(); LogBox->Update(); wxSafeYield(); wxMutexGuiLeave(); // Scans file bool fileModified = false; AssStyle *curStyle; AssDialogue *curDiag; curLine = 0; for (std::list<AssEntry*>::iterator cur=subs->Line.begin();cur!=subs->Line.end();cur++) { // Collect from style curStyle = AssEntry::GetAsStyle(*cur); if (curStyle) { AddFont(curStyle->font,true); wxMutexGuiEnter(); LogBox->AppendText(wxString(_T("\"")) + curStyle->font + _("\" found on style \"") + curStyle->name + _T("\".\n")); LogBox->Refresh(); LogBox->Update(); wxSafeYield(); wxMutexGuiLeave(); } // Collect from dialogue else { curDiag = AssEntry::GetAsDialogue(*cur); if (curDiag) { curLine++; curDiag->ParseASSTags(); curDiag->ProcessParameters(GetFonts); curDiag->ClearBlocks(); } } } #ifdef __WINDOWS__ // Collect font data wxMutexGuiEnter(); LogBox->SetDefaultStyle(wxTextAttr(wxColour(0,0,180))); LogBox->AppendText(_("\nReading fonts from registry...\n")); LogBox->SetDefaultStyle(wxTextAttr(wxColour(0,0,0))); wxSafeYield(); wxMutexGuiLeave(); CollectFontData(); // Get fonts folder wxString source; TCHAR szPath[MAX_PATH]; if (SUCCEEDED(SHGetFolderPath(NULL, CSIDL_FONTS,NULL,0,szPath))) { source = wxString(szPath); } else source = wxGetOSDirectory() + _T("\\fonts"); source += _T("\\"); // Get font file names wxArrayString work; wxArrayString copied; bool attaching = collector->AttachmentCheck->IsChecked(); for (size_t i=0;i<fonts.GetCount();i++) { try { work = GetFontFiles(fonts[i]); for (size_t j=0;j<work.GetCount();j++) { // Get path to font file wxString srcFile,dstFile; wxFileName srcFileName(work[j]); if (srcFileName.FileExists() && srcFileName.IsAbsolute()) { srcFile = work[j]; dstFile = destination + srcFileName.GetFullName(); } else { srcFile = source + work[j]; dstFile = destination + work[j]; } if (copied.Index(work[j]) == wxNOT_FOUND) { copied.Add(work[j]); // Check if it exists if (!attaching && wxFileName::FileExists(dstFile)) { wxMutexGuiEnter(); LogBox->SetDefaultStyle(wxTextAttr(wxColour(255,128,0))); LogBox->AppendText(wxString(_T("\"")) + work[j] + _("\" already exists on destination.\n")); LogBox->Refresh(); LogBox->Update(); wxSafeYield(); wxMutexGuiLeave(); } // Copy else { // Copy font bool success; if (attaching) { try { subs->InsertAttachment(srcFile); fileModified = true; success = true; } catch (...) { success = false; } } else success = Copy(srcFile,dstFile); // Report wxMutexGuiEnter(); if (success) { LogBox->SetDefaultStyle(wxTextAttr(wxColour(0,180,0))); LogBox->AppendText(wxString(_T("\"")) + work[j] + _("\" copied.\n")); } else { LogBox->SetDefaultStyle(wxTextAttr(wxColour(220,0,0))); LogBox->AppendText(wxString(_("Failed copying \"")) + srcFile + _T("\".\n")); } LogBox->Refresh(); LogBox->Update(); wxSafeYield(); wxMutexGuiLeave(); } } } } catch (...) { wxMutexGuiEnter(); LogBox->SetDefaultStyle(wxTextAttr(wxColour(220,0,0))); LogBox->AppendText(wxString(_("Could not find font ")) + fonts[i] + _T("\n")); wxMutexGuiLeave(); } } #endif // Flag file as modified if (fileModified) { subs->FlagAsModified(); collector->main->SubsBox->CommitChanges(); } }
/* static */ wxString wxPlatformInfo::GetOperatingSystemDirectory() { return wxGetOSDirectory(); }
AutoDetectResult CompilerG95::AutoDetectInstallationDir() { // try to find MinGW in environment variable PATH first wxString pathValues; wxGetEnv(_T("PATH"), &pathValues); if (!pathValues.IsEmpty()) { wxString sep = platform::windows ? _T(";") : _T(":"); wxChar pathSep = platform::windows ? _T('\\') : _T('/'); wxArrayString pathArray = GetArrayFromString(pathValues, sep); for (size_t i = 0; i < pathArray.GetCount(); ++i) { if (wxFileExists(pathArray[i] + pathSep + m_Programs.C)) { if (pathArray[i].AfterLast(pathSep).IsSameAs(_T("bin"))) { m_MasterPath = pathArray[i].BeforeLast(pathSep); return adrDetected; } } } } wxString sep = wxFileName::GetPathSeparator(); if (platform::windows) { // look first if MinGW was installed with Code::Blocks (new in beta6) m_MasterPath = ConfigManager::GetExecutableFolder(); if (!wxFileExists(m_MasterPath + sep + _T("bin") + sep + m_Programs.C)) // if that didn't do it, look under C::B\MinGW, too (new in 08.02) m_MasterPath += sep + _T("MinGW"); if (!wxFileExists(m_MasterPath + sep + _T("bin") + sep + m_Programs.C)) { // no... search for MinGW installation dir wxString windir = wxGetOSDirectory(); wxFileConfig ini(_T(""), _T(""), windir + _T("/MinGW.ini"), _T(""), wxCONFIG_USE_LOCAL_FILE | wxCONFIG_USE_NO_ESCAPE_CHARACTERS); m_MasterPath = ini.Read(_T("/InstallSettings/InstallPath"), _T("C:\\MinGW")); if (!wxFileExists(m_MasterPath + sep + _T("bin") + sep + m_Programs.C)) { #ifdef __WXMSW__ // for wxRegKey // not found... // look for dev-cpp installation wxRegKey key; // defaults to HKCR key.SetName(_T("HKEY_LOCAL_MACHINE\\Software\\Dev-C++")); if (key.Exists() && key.Open(wxRegKey::Read)) { // found; read it key.QueryValue(_T("Install_Dir"), m_MasterPath); } else { // installed by inno-setup // HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\Minimalist GNU for Windows 4.1_is1 wxString name; long index; key.SetName(_T("HKEY_LOCAL_MACHINE\\SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Uninstall")); //key.SetName("HKEY_LOCAL_MACHINE\\SOFTWARE\\Microsoft\\Windows\\CurrentVersion"); bool ok = key.GetFirstKey(name, index); while (ok && !name.StartsWith(_T("Minimalist GNU for Windows"))) { ok = key.GetNextKey(name, index); } if (ok) { name = key.GetName() + _T("\\") + name; key.SetName(name); if (key.Exists() && key.Open(wxRegKey::Read)) key.QueryValue(_T("InstallLocation"), m_MasterPath); } } #endif } } else m_Programs.MAKE = _T("make.exe"); // we distribute "make" not "mingw32-make" } else m_MasterPath = _T("/usr"); AutoDetectResult ret = wxFileExists(m_MasterPath + sep + _T("bin") + sep + m_Programs.C) ? adrDetected : adrGuessed; // don't add lib/include dirs. GCC knows where its files are located SetVersionString(); return ret; }