bool Project::SaveXmlFile() { bool ok = m_doc.Save(m_fileName.GetFullPath()); SetProjectLastModifiedTime(GetFileLastModifiedTime()); wxCommandEvent evt(wxEVT_FILE_SAVED); evt.SetString( m_fileName.GetFullPath() ); EventNotifier::Get()->AddPendingEvent( evt ); return ok; }
bool Project::SaveXmlFile() { wxString projectXml; wxStringOutputStream sos( &projectXml ); bool ok = m_doc.Save( sos ); wxFFile file(m_fileName.GetFullPath(), wxT("w+b")); if ( !file.IsOpened() ) { ok = false; } else { file.Write( projectXml ); file.Close(); } SetProjectLastModifiedTime(GetFileLastModifiedTime()); EventNotifier::Get()->PostFileSavedEvent( m_fileName.GetFullPath() ); return ok; }
bool clCxxWorkspace::SaveXmlFile() { // We first remove the Save Workspace To Local Workspace (SWTLW) attribute // and then check the current state in the Code Completion tab. Then // we read new path values from the LW and set the appropiate attribute value. if(m_doc.GetRoot()->GetAttribute(wxT("SWTLW")) != wxEmptyString) { m_doc.GetRoot()->DeleteAttribute(wxT("SWTLW")); } if(LocalWorkspaceST::Get()->GetParserFlags() & LocalWorkspace::EnableSWTLW) { m_doc.GetRoot()->AddProperty(wxT("SWTLW"), "Yes"); SyncFromLocalWorkspaceSTParserPaths(); SyncFromLocalWorkspaceSTParserMacros(); } bool ok = m_doc.Save(m_fileName.GetFullPath()); SetWorkspaceLastModifiedTime(GetFileLastModifiedTime()); EventNotifier::Get()->PostFileSavedEvent(m_fileName.GetFullPath()); DoUpdateBuildMatrix(); return ok; }
bool Project::Load(const wxString &path) { if ( !m_doc.Load(path) ) { return false; } ConvertToUnixFormat(m_doc.GetRoot()); // Workaround WX bug: load the plugins data (GetAllPluginsData will strip any trailing whitespaces) // and then set them back std::map<wxString, wxString> pluginsData; GetAllPluginsData(pluginsData); SetAllPluginsData(pluginsData, false); m_vdCache.clear(); m_fileName = path; m_fileName.MakeAbsolute(); SetModified(true); SetProjectLastModifiedTime(GetFileLastModifiedTime()); return true; }
bool clCxxWorkspace::OpenWorkspace(const wxString& fileName, wxString& errMsg) { CloseWorkspace(); m_buildMatrix.Reset(NULL); wxFileName workSpaceFile(fileName); if(workSpaceFile.FileExists() == false) { errMsg = wxString::Format(wxT("Could not open workspace file: '%s'"), fileName.c_str()); return false; } m_fileName = workSpaceFile; m_doc.Load(m_fileName.GetFullPath()); if(!m_doc.IsOk()) { errMsg = wxT("Corrupted workspace file"); return false; } // Make sure we have the WORKSPACE/.codelite folder exists { wxLogNull nolog; wxMkdir(GetPrivateFolder()); } SetWorkspaceLastModifiedTime(GetFileLastModifiedTime()); // This function sets the working directory to the workspace directory! ::wxSetWorkingDirectory(m_fileName.GetPath()); // Load all projects wxXmlNode* child = m_doc.GetRoot()->GetChildren(); std::vector<wxXmlNode*> removedChildren; wxString tmperr; while(child) { if(child->GetName() == wxT("Project")) { wxString projectPath = child->GetPropVal(wxT("Path"), wxEmptyString); if(!DoAddProject(projectPath, errMsg)) { tmperr << wxString::Format(wxT("Error occured while loading project: \"%s\"\nCodeLite has removed the " "faulty project from the workspace\n"), projectPath.c_str()); removedChildren.push_back(child); } } else if((child->GetName() == wxT("WorkspaceParserPaths")) || (child->GetName() == wxT("WorkspaceParserMacros"))) { wxString swtlw = wxEmptyString; swtlw = XmlUtils::ReadString(m_doc.GetRoot(), "SWTLW"); if(swtlw.CmpNoCase("yes") == 0) { LocalWorkspaceST::Get()->SetParserFlags(LocalWorkspaceST::Get()->GetParserFlags() | LocalWorkspace::EnableSWTLW); SyncToLocalWorkspaceSTParserPaths(); SyncToLocalWorkspaceSTParserMacros(); } } child = child->GetNext(); } // Delete the faulty projects for(size_t i = 0; i < removedChildren.size(); i++) { wxXmlNode* ch = removedChildren.at(i); ch->GetParent()->RemoveChild(ch); delete ch; } errMsg.Clear(); TagsManager* mgr = TagsManagerST::Get(); mgr->CloseDatabase(); mgr->OpenDatabase(GetTagsFileName().GetFullPath()); // Update the build matrix DoUpdateBuildMatrix(); // Notify about active project changed ProjectPtr activeProject = GetActiveProject(); if(activeProject) { clProjectSettingsEvent evt(wxEVT_ACTIVE_PROJECT_CHANGED); evt.SetProjectName(activeProject->GetName()); evt.SetFileName(activeProject->GetFileName().GetFullPath()); EventNotifier::Get()->AddPendingEvent(evt); } return true; }