bool wxMkdir(const wxString& dir, int perm) { #if defined(__WXMAC__) && !defined(__UNIX__) if ( mkdir(dir.fn_str(), 0) != 0 ) // assume mkdir() has 2 args on all platforms // for the GNU compiler #elif (!defined(__WINDOWS__)) || \ (defined(__GNUWIN32__) && !defined(__MINGW32__)) || \ defined(__WINE__) const wxChar *dirname = dir.c_str(); #if defined(MSVCRT) wxUnusedVar(perm); if ( mkdir(wxFNCONV(dirname)) != 0 ) #else if ( mkdir(wxFNCONV(dirname), perm) != 0 ) #endif #else // MSW and VC++ wxUnusedVar(perm); if ( wxMkDir(dir.fn_str()) != 0 ) #endif // !MSW/MSW { wxLogSysError(_("Directory '%s' couldn't be created"), dir); return false; } return true; }
bool InstallLangFiles() { if (!wxDirExists(langDir)) wxMkDir(langDir,wxS_DIR_DEFAULT); const int langFileCount = 3; LangFileDef langFiles[] = { DEFINE_LANGFILE(en_us), DEFINE_LANGFILE(en_gb), DEFINE_LANGFILE(ru_ru), // DEFINE_LANGFILE(es_mx), translation is not complete yet }; for (int i = 0; i < langFileCount; i++) { wxString dir = Path::Combine(langDir, langFiles[i].m_dirName); if (!wxDirExists(dir) && !wxMkdir(dir)) { wxLogError(_("Can't install localizations. Failed to create directory.")); return false; } // Write the file. wxString moFileName = Path::Combine(dir, "MultiMC.mo"); wxMemoryInputStream inStream(langFiles[i].m_data, langFiles[i].m_dataSize); wxFFileOutputStream outStream(moFileName); outStream.Write(inStream); } }
void EffectNoiseRemoval::CleanSpeechMayWriteNoiseGate() { AudacityProject * project = GetActiveProject(); if( !project || !project->GetCleanSpeechMode() ) return; // code borrowed from ThemeBase::SaveComponents() - MJS // IF directory doesn't exist THEN create it if( !wxDirExists( FileNames::NRPDir() )) { /// \bug 1 in wxWidgets documentation; wxMkDir returns false if /// directory didn't exist, even if it successfully creates it. /// so we create and then test if it exists instead. /// \bug 2 in wxWidgets documentation; wxMkDir has only one argument /// under MSW #ifdef __WXMSW__ wxMkDir( FileNames::NRPDir().fn_str() ); #else wxMkDir( FileNames::NRPDir().fn_str(), 0700 ); #endif if( !wxDirExists( FileNames::NRPDir() )) { wxMessageBox( wxString::Format( _("Could not create directory:\n %s"), FileNames::NRPDir().c_str() )); return; } } wxString fileName = FileNames::NRPFile(); fileName = PlatformCompatibility::GetLongFileName(fileName); wxFFile noiseGateFile(fileName, wxT("wb")); bool flag = noiseGateFile.IsOpened(); if (flag == true) { int expectedCount = (mWindowSize / 2) * sizeof(float); // FIX-ME: Should we check return value on Write? noiseGateFile.Write(mNoiseThreshold, expectedCount); noiseGateFile.Close(); } else { wxMessageBox( wxString::Format( _("Could not open file:\n %s"), fileName.c_str() )); return; } }
void reProjectAssets::EnsureAssetDir(const wxString& dirName) { wxFileName assetDir(m_assetsDir); assetDir.AppendDir(dirName); if (!assetDir.Exists()) { wxMkDir(assetDir.GetPath(), wxS_DIR_DEFAULT); } }
StandardPaths::StandardPaths() { wxStandardPathsBase &paths = wxStandardPaths::Get(); #if defined(__UNIX__) && !defined(__APPLE__) // Relocation support, this is required to set the prefix to all // wx StandardPaths. static_cast<wxStandardPaths&>(paths).SetInstallPrefix(wxT(INSTALL_PREFIX)); #endif DoSetPathValue("?data", paths.GetDataDir()); DoSetPathValue("?user", paths.GetUserDataDir()); DoSetPathValue("?local", paths.GetUserLocalDataDir()); DoSetPathValue("?temp", paths.GetTempDir()); // Create paths if they don't exist if (!wxDirExists(paths.GetUserDataDir())) wxMkDir(paths.GetUserDataDir(), 0777); if (!wxDirExists(paths.GetUserLocalDataDir())) wxMkDir(paths.GetUserLocalDataDir(), 0777); }
void gvVisionManager::Init_ImageDir() { wxFileName filename(m_strConfigFile); wxString dir = wxGetCwd() + wxT("\\images\\"); dir = dir + filename.GetName(); wxMkDir( dir ); wxDateTime date = wxDateTime::Today(); dir = dir + wxString::Format( wxT("\\%d-%02d-%02d"), date.GetYear(), date.GetMonth()+1, date.GetDay() ); wxMkDir( dir ); int iIndex = 0; for ( iIndex=0; iIndex<HGV_SUPPORT_CAMERANUM; iIndex++ ) { m_strImageDir[iIndex] = dir + wxString::Format( wxT("\\CCD%d"), iIndex+1 ); wxMkDir( m_strImageDir[iIndex] ); } }
std::string GNC::Entorno::CrearDirectorioTemporal() { wxString dirTmp; do { std::ostringstream ostr; ostr << GetGinkgoTempDir().c_str() << (char)wxFileName::GetPathSeparator() << "_gnktmp_" << rand(); dirTmp = FROMPATH(ostr.str()); } while (wxDirExists(dirTmp)); #if defined(_WINDOWS) bool success = wxMkDir(dirTmp); #else bool success = wxMkDir(dirTmp.ToUTF8(), 0770); #endif std::string resultado(TOPATH(dirTmp)); if (!success) { LOG_ERROR("Core", "Error creating temporary directory '"<<resultado << "'"); } return resultado; }
void ThemeBase::SaveComponents() { // IF directory doesn't exist THEN create it if( !wxDirExists( FileNames::ThemeComponentsDir() )) { /// \bug 1 in wxWidgets documentation; wxMkDir returns false if /// directory didn't exist, even if it successfully creates it. /// so we create and then test if it exists instead. /// \bug 2 in wxWidgets documentation; wxMkDir has only one argument /// under MSW #ifdef __WXMSW__ wxMkDir( FileNames::ThemeComponentsDir().fn_str() ); #else wxMkDir( FileNames::ThemeComponentsDir().fn_str(), 0700 ); #endif if( !wxDirExists( FileNames::ThemeComponentsDir() )) { wxMessageBox( wxString::Format( _("Could not create directory:\n %s"), FileNames::ThemeComponentsDir().c_str() )); return; } } wxBusyCursor busy; int i; int n=0; wxString FileName; for(i=0;i<(int)mImages.GetCount();i++) { if( (mBitmapFlags[i] & resFlagInternal)==0) { FileName = FileNames::ThemeComponent( mBitmapNames[i] ); if( !wxFileExists( FileName )) { if( !mImages[i].SaveFile( FileName, wxBITMAP_TYPE_PNG )) { wxMessageBox( wxString::Format( _("Audacity could not save file:\n %s"), FileName.c_str() )); return; } n++; } } } if( n==0 ) { wxMessageBox( wxString::Format( _("All required files in:\n %s\nwere already present."), FileNames::ThemeComponentsDir().c_str() )); return; } wxMessageBox( wxString::Format( wxT("Theme written to:\n %s."), FileNames::ThemeComponentsDir().c_str() )); }
virtual void startLogging( wxCommandEvent& event ) { if (!wxDir::Exists(logDir->GetValue())) { int res = wxMessageBox(wxT("Directory: ") + logDir->GetValue() + wxT(" does not exist. Create it now?"), wxT(""), wxOK | wxCANCEL); if (res == wxCANCEL) { event.Skip(); return; } if (wxMkDir(logDir->GetValue().mb_str(wxConvUTF8), 0755) < 0) { wxMessageBox(wxT("Could not make directory: ") + logDir->GetValue()); event.Skip(); return; } } std::vector<std::string> selections = topicDisplay->getSelectedTopics(); if (selections.size() == 0) { wxMessageBox(wxT("No topics selected.")); event.Skip(); return; } wxDateTime time = wxDateTime::Now(); wxString dirName = logDir->GetValue() + wxT("/") + time.Format(wxT("%Y-%m-%d-%H-%M-%S")); if (wxMkDir(dirName.mb_str(wxConvUTF8), 0755) < 0) { wxMessageBox(wxT("Could not make directory: ") + dirName); event.Skip(); return; } stopLogButton->Enable(true); startLogButton->Enable(false); statusBar->SetStatusText(wxT("Logging...")); ros::Time start = ros::Time::now(); for (std::vector<std::string>::iterator i = selections.begin(); i != selections.end(); i++) { printf("vacuuming up [%s]\n", i->c_str()); std::string sanitizedName = *i; for (size_t j = 0; j < sanitizedName.length(); j++) { char c = sanitizedName[j]; // sanitize it a bit if (c == '\\' || c == '/' || c == '#' || c == '&' || c == ';') sanitizedName[j] = '_'; } LogRecorder<>* bag = new LogRecorder<>; sanitizedName = std::string( dirName.mb_str(wxConvUTF8) ) + std::string("/") + sanitizedName + std::string(".bag"); if (bag->open_log(sanitizedName, node->map_name(*i), start)) { node->subscribe(*i, *bag, &LogGui::dummyCb, this); bags.push_back(bag); } else { delete bag; } } event.Skip(); }
bool MyApp::OnInit() { // MSW: Perhaps that is faster. wxSystemOptions::SetOption("msw.display.directdraw","1"); // No spell checking in our dialog's input portions on the mac. wxSystemOptions::SetOption("mac.textcontrol-use-spell-checker","0"); // Migrate an eventual old config file to the location XDG wants it to be. #ifndef __WXMSW__ #if wxCHECK_VERSION(3, 1, 1) wxStandardPaths::Get().SetFileLayout(wxStandardPaths::FileLayout_Classic); wxString configFileOld = wxStandardPaths::Get().GetUserConfigDir() + wxT("/") + wxStandardPaths::Get().MakeConfigFileName( wxString(wxT("wxMaxima")), wxStandardPaths::ConfigFileConv_Dot); wxStandardPaths::Get().SetFileLayout(wxStandardPaths::FileLayout_XDG); wxString configFileXDG = wxStandardPaths::Get().GetUserConfigDir() + wxT("/") + wxStandardPaths::Get().MakeConfigFileName( wxString(wxT("wxMaxima")), wxStandardPaths::ConfigFileConv_Ext); if(!wxFileExists(configFileXDG)) { wxFileName xdgDir(configFileXDG); wxString dirName(xdgDir.GetPath()); if(!wxDirExists(dirName)) wxMkDir(dirName,0x700); wxLogNull blocker; if(wxFileExists(configFileOld)) wxCopyFile(configFileOld,configFileXDG); } #endif #endif wxConfig::Set(new wxFileConfig(wxT("wxMaxima"), wxEmptyString, m_configFileName)); atexit(Cleanup); int lang = wxLANGUAGE_UNKNOWN; bool exitAfterEval = false; bool evalOnStartup = false; wxCmdLineParser cmdLineParser(argc, argv); static const wxCmdLineEntryDesc cmdLineDesc[] = { {wxCMD_LINE_SWITCH, "v", "version", "Output the version info", wxCMD_LINE_VAL_NONE , 0}, /* Usually wxCMD_LINE_OPTION_HELP is used with the following option, but that displays a message * using a own window and we want the message on the command line. If a user enters a command * line option, he expects probably a answer just on the command line... */ {wxCMD_LINE_SWITCH, "h", "help", "show this help message", wxCMD_LINE_VAL_NONE, wxCMD_LINE_OPTION_HELP}, {wxCMD_LINE_OPTION, "o", "open", "open a file", wxCMD_LINE_VAL_STRING , 0}, {wxCMD_LINE_SWITCH, "e", "eval", "evaluate the file after opening it.", wxCMD_LINE_VAL_NONE , 0}, {wxCMD_LINE_SWITCH, "b", "batch", "run the file and exit afterwards. Halts on questions and stops on errors.", wxCMD_LINE_VAL_NONE, 0}, { wxCMD_LINE_OPTION, "f", "ini", "allows to specify a file to store the configuration in", wxCMD_LINE_VAL_STRING , 0}, { wxCMD_LINE_OPTION, "m", "maxima", "allows to specify the location of the maxima binary", wxCMD_LINE_VAL_STRING , 0}, {wxCMD_LINE_PARAM, NULL, NULL, "input file", wxCMD_LINE_VAL_STRING, wxCMD_LINE_PARAM_OPTIONAL | wxCMD_LINE_PARAM_MULTIPLE}, {wxCMD_LINE_NONE, "", "", "", wxCMD_LINE_VAL_NONE, 0} }; cmdLineParser.SetDesc(cmdLineDesc); cmdLineParser.Parse(); wxString ini, file; // Attention: The config file is changed by wxMaximaFrame::wxMaximaFrame::ReReadConfig if (cmdLineParser.Found(wxT("f"),&ini)) { Configuration::m_maximaLocation_override = ini; } else wxConfig::Set(new wxConfig(wxT("wxMaxima"))); if (cmdLineParser.Found(wxT("m"),&ini)) wxConfig::Get()->Write(wxT("maxima"), ini); wxImage::AddHandler(new wxPNGHandler); wxImage::AddHandler(new wxXPMHandler); wxImage::AddHandler(new wxJPEGHandler); wxFileSystem::AddHandler(new wxZipFSHandler); wxConfigBase *config = wxConfig::Get(); lang = wxLocale::GetSystemLanguage(); config->Read(wxT("language"), &lang); if(wxLocale::IsAvailable(lang)) m_locale.Init(lang); else m_locale.Init(wxLANGUAGE_ENGLISH); m_dirstruct = new Dirstructure; if((lang != wxLANGUAGE_UNKNOWN) && (lang != wxLANGUAGE_DEFAULT) && (lang != wxLocale::GetSystemLanguage())) wxSetEnv(wxT("LANG"), m_locale.GetCanonicalName()); #ifdef __WXMSW__ wxString oldWorkingDir = wxGetCwd(); if (!wxGetEnv(wxT("BUILD_DIR"), NULL)) { wxString dir = wxPathOnly(wxStandardPaths::Get().GetExecutablePath()); if(dir != wxEmptyString) wxSetWorkingDirectory(wxPathOnly(wxStandardPaths::Get().GetExecutablePath())); } wxString fontPrefix = m_dirstruct->FontDir() + wxT("/"); /* Add private jsMath fonts, if they exist */ #if wxCHECK_VERSION(3, 1, 1) if (wxFileExists(fontPrefix + wxT(CMEX10) + wxT(".ttf"))) wxFont::AddPrivateFont(fontPrefix + wxT(CMEX10) + wxT(".ttf")); if (wxFileExists(fontPrefix + wxT(CMSY10) + wxT(".ttf"))) wxFont::AddPrivateFont(fontPrefix + wxT(CMSY10) + wxT(".ttf")); if (wxFileExists(fontPrefix + wxT(CMR10) + wxT(".ttf"))) wxFont::AddPrivateFont(fontPrefix + wxT(CMR10) + wxT(".ttf")); if (wxFileExists(fontPrefix + wxT(CMMI10) + wxT(".ttf"))) wxFont::AddPrivateFont(fontPrefix + wxT(CMMI10) + wxT(".ttf")); if (wxFileExists(fontPrefix + wxT(CMTI10) + wxT(".ttf"))) wxFont::AddPrivateFont(fontPrefix + wxT(CMTI10) + wxT(".ttf")); /* Add private Libertine fonts, if they exist */ if (wxFileExists(fontPrefix + wxT(LIBERTINE1))) wxFont::AddPrivateFont(fontPrefix + wxT(LIBERTINE1)); if (wxFileExists(fontPrefix + wxT(LIBERTINE2))) wxFont::AddPrivateFont(fontPrefix + wxT(LIBERTINE2)); if (wxFileExists(fontPrefix + wxT(LIBERTINE3))) wxFont::AddPrivateFont(fontPrefix + wxT(LIBERTINE3)); if (wxFileExists(fontPrefix + wxT(LIBERTINE4))) wxFont::AddPrivateFont(fontPrefix + wxT(LIBERTINE4)); if (wxFileExists(fontPrefix + wxT(LIBERTINE5))) wxFont::AddPrivateFont(fontPrefix + wxT(LIBERTINE5)); if (wxFileExists(fontPrefix + wxT(LIBERTINE6))) wxFont::AddPrivateFont(fontPrefix + wxT(LIBERTINE6)); if (wxFileExists(fontPrefix + wxT(LIBERTINE7))) wxFont::AddPrivateFont(fontPrefix + wxT(LIBERTINE7)); if (wxFileExists(fontPrefix + wxT(LIBERTINE8))) wxFont::AddPrivateFont(fontPrefix + wxT(LIBERTINE8)); if (wxFileExists(fontPrefix + wxT(LIBERTINE9))) wxFont::AddPrivateFont(fontPrefix + wxT(LIBERTINE9)); #endif wxSetWorkingDirectory(oldWorkingDir); #endif m_locale.AddCatalogLookupPathPrefix(m_dirstruct->LocaleDir()); m_locale.AddCatalogLookupPathPrefix(m_dirstruct->LocaleDir()+wxT("/wxwin")); m_locale.AddCatalogLookupPathPrefix(wxT("/usr/share/locale")); m_locale.AddCatalogLookupPathPrefix(wxT("/usr/local/share/locale")); m_locale.AddCatalog(wxT("wxMaxima")); m_locale.AddCatalog(wxT("wxMaxima-wxstd")); #if defined __WXMAC__ wxString path; wxGetEnv(wxT("PATH"), &path); wxSetEnv(wxT("PATH"), path << wxT(":/usr/local/bin")); wxApp::SetExitOnFrameDelete(false); wxMenuBar *menuBar = new wxMenuBar; wxMenu *fileMenu = new wxMenu; fileMenu->Append(wxMaxima::mac_newId, _("&New\tCtrl+N")); fileMenu->Append(wxMaxima::mac_openId, _("&Open\tCtrl+O")); menuBar->Append(fileMenu, _("File")); wxMenuBar::MacSetCommonMenuBar(menuBar); Connect(wxMaxima::mac_newId, wxEVT_COMMAND_MENU_SELECTED, wxCommandEventHandler(MyApp::OnFileMenu)); Connect(wxMaxima::mac_openId, wxEVT_COMMAND_MENU_SELECTED, wxCommandEventHandler(MyApp::OnFileMenu)); Connect(wxID_EXIT, wxEVT_COMMAND_MENU_SELECTED, wxCommandEventHandler(MyApp::OnFileMenu)); #endif if (cmdLineParser.Found(wxT("v"))) { std::cout << "wxMaxima "; std::cout << GITVERSION; #if defined(WXMAXIMA_GIT_VERSION) std::cout << " (Git version: " << WXMAXIMA_GIT_VERSION << ")"; #endif std::cout << "\n"; wxExit(); } if (cmdLineParser.Found(wxT("h"))) { std::cout << "A feature-rich graphical user interface for the computer algebra system maxima\n"; std::cout << cmdLineParser.GetUsageString(); wxExit(); } if (cmdLineParser.Found(wxT("b"))) { evalOnStartup = true; exitAfterEval = true; } if (cmdLineParser.Found(wxT("e"))) evalOnStartup = true; if (cmdLineParser.Found(wxT("o"), &file)) { wxFileName FileName = file; FileName.MakeAbsolute(); wxString CanonicalFilename = FileName.GetFullPath(); NewWindow(wxString(CanonicalFilename), evalOnStartup, exitAfterEval); return true; } if(cmdLineParser.GetParamCount() > 0) { for (unsigned int i=0; i < cmdLineParser.GetParamCount(); i++) { wxFileName FileName = cmdLineParser.GetParam(i); FileName.MakeAbsolute(); wxString CanonicalFilename = FileName.GetFullPath(); NewWindow(CanonicalFilename, evalOnStartup, exitAfterEval); } } else NewWindow(); return true; }
GNC::Entorno::Entorno() { DJEncoderRegistration::registerCodecs( ECC_lossyYCbCr, EUC_default, // UID generation (never create new UID's) OFFalse, // verbose 0, 0, 0, true, ESS_444, true); // optimize huffman table DJDecoderRegistration::registerCodecs(); DcmRLEEncoderRegistration::registerCodecs(); DcmRLEDecoderRegistration::registerCodecs(); m_pApp = NULL; m_pVentanaPrincipal = NULL; m_pVentanaRaiz = NULL; m_GinkgoLicenseMessage = ""; m_isChildInstance = false; std::ostringstream os; os << GINKGO_VERSION; if (sizeof(void*) == 4) { os << " 32 bits"; } else if (sizeof(void*) == 8) { os << " 64 bits"; } std::sscanf(GINKGO_VERSION, "%u.%u.%*c", &m_mayorVersionNumber, &m_minorVersionNumber); m_GinkgoVersion = os.str(); m_GinkgoCopyRight = GINKGO_COPYRIGHT; wxFileName executable_path = wxStandardPaths::Get().GetExecutablePath(); //executable_path.SetFullName(wxEmptyString); wxString pluginsDir; wxString resourcesDir; wxString langDir; #if defined(_WINDOWS) pluginsDir = executable_path.GetPath() + wxFileName::GetPathSeparator() + wxT("Plugins"); langDir = executable_path.GetPath() + wxFileName::GetPathSeparator() + wxT("lang"); resourcesDir = executable_path.GetPath(); #elif defined(LINUX) #if defined(CUSTOM_PACKAGE) pluginsDir = executable_path.GetPath() + wxFileName::GetPathSeparator() + wxT("Plugins"); resourcesDir = executable_path.GetPath(); langDir = executable_path.GetPath() + wxFileName::GetPathSeparator() + wxT("lang"); #else pluginsDir = wxStandardPaths::Get().GetPluginsDir() + wxFileName::GetPathSeparator() + wxT("Plugins"); resourcesDir = wxStandardPaths::Get().GetResourcesDir(); langDir = wxStandardPaths::Get().GetResourcesDir() + wxFileName::GetPathSeparator() + wxT("lang"); #endif #else pluginsDir = wxStandardPaths::Get().GetPluginsDir(); langDir = wxStandardPaths::Get().GetResourcesDir() + wxFileName::GetPathSeparator() + wxT("lang"); resourcesDir = wxStandardPaths::Get().GetResourcesDir(); #endif m_GinkgoPluginsDir = TOPATH(pluginsDir); m_GinkgoLanguageDir = TOPATH(langDir); m_GinkgoResourcesDir = TOPATH(resourcesDir); //std::cout << "PLUGINS_DIR = " << m_GinkgoPluginsDir.c_str() << std::endl; //std::cout << "LANGUAGE_DIR = " << m_GinkgoLanguageDir.c_str() << std::endl; wxString wxTempDir = wxStandardPaths::Get().GetTempDir() + wxFileName::GetPathSeparator() + wxT("GinkgoCADx"); m_GinkgoTempDir = TOPATH(wxTempDir); if (!wxDirExists(wxTempDir)) { bool success; #ifdef _WIN32 success = wxMkdir(wxTempDir,511); #else success = (wxMkDir(wxTempDir.ToUTF8(), 0770) == 0); #endif if (!success) { LOG_ERROR("Core", "Unable to create temporary directory '" << m_GinkgoTempDir << "'"); } } m_GinkgoUserDir = TOPATH(wxStandardPaths::Get().GetUserDataDir()); { wxString directorioUser = FROMPATH(m_GinkgoUserDir); //se crea el user dir if(!wxDirExists(directorioUser)) { bool success; #ifdef _WIN32 success = wxMkdir(directorioUser,511); #else success = (wxMkDir(directorioUser.ToUTF8(), 0770) == 0); #endif if (!success) { LOG_ERROR("Core", "Unable to create user directory '" << m_GinkgoUserDir << "'"); } } } // Carga de ubicaciones GNC::GCS::ConfigurationController::TListGroups locations; GNC::GCS::ConfigurationController::Instance()->readGroupGeneral("/GinkgoCore/Locations", locations); for (GNC::GCS::ConfigurationController::TListGroups::iterator it = locations.begin(); it != locations.end(); ++it) { std::string title, path, descr; bool monitorize, cleanbefore, cleanafter; (*it).readStringValue("Title", title); (*it).readStringValue("Path", path); (*it).readStringValue("Description", descr); (*it).readBoolValue("Monitorize", monitorize, false); (*it).readBoolValue("CleanBefore", cleanbefore, false); (*it).readBoolValue("CleanAfter", cleanafter, false); m_Ubicaciones[title] = new GIL::Ubicacion(title, path, descr, monitorize, cleanbefore, cleanafter); } GIL::IntegrationController::Instance(); }