MCPcopy Create free account
hub / github.com/SpartanJ/eepp / saveProject

Method saveProject

src/tools/ecode/appconfig.cpp:572–688  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

570}
571
572void AppConfig::saveProject( std::string projectFolder, UICodeEditorSplitter* editorSplitter,
573 const std::string& configPath, const ProjectConfig& docConfig,
574 const ProjectBuildConfiguration& buildConfig, bool onlyIfNeeded,
575 bool sessionSnapshot, PluginManager* pluginManager ) {
576 FileSystem::dirAddSlashAtEnd( projectFolder );
577 std::string projectsPath( configPath + "projects" + FileSystem::getOSSlash() );
578 if ( !FileSystem::fileExists( projectsPath ) )
579 FileSystem::makeDir( projectsPath );
580 MD5::Result hash = MD5::fromString( projectFolder );
581 std::string projectCfgPath( projectsPath + hash.toHexString() + ".cfg" );
582 IniFile cfg( projectCfgPath, false );
583 cfg.setValue( "path", "folder_path", projectFolder );
584 cfg.setValueB( "document", "use_global_settings", docConfig.useGlobalSettings );
585 cfg.setValue( "document", "h_ext_language_type",
586 HExtLanguageTypeHelper::toString( docConfig.hExtLanguageType ) );
587 cfg.setValueB( "document", "trim_trailing_whitespaces", docConfig.doc.trimTrailingWhitespaces );
588 cfg.setValueB( "document", "force_new_line_at_end_of_file",
589 docConfig.doc.forceNewLineAtEndOfFile );
590 cfg.setValueB( "document", "auto_detect_indent_type", docConfig.doc.autoDetectIndentType );
591 cfg.setValue( "document", "auto_indent", autoIndentToString( docConfig.doc.autoIndent ) );
592 cfg.setValueB( "document", "write_bom", docConfig.doc.writeUnicodeBOM );
593 cfg.setValueI( "document", "indent_width", docConfig.doc.indentWidth );
594 cfg.setValueB( "document", "indent_spaces", docConfig.doc.indentSpaces );
595 cfg.setValue( "document", "line_endings",
596 TextFormat::lineEndingToString( docConfig.doc.lineEndings ) );
597 cfg.setValueI( "document", "tab_width", docConfig.doc.tabWidth );
598 cfg.setValueI( "document", "line_breaking_column", docConfig.doc.lineBreakingColumn );
599 cfg.setValue( "build", "build_name", buildConfig.buildName );
600 cfg.setValue( "build", "build_type", buildConfig.buildType );
601 cfg.setValue( "build", "run_name", buildConfig.runName );
602 cfg.setValue( "nodes", "documents",
603 saveNode( editorSplitter->getBaseLayout()->getFirstChild() ).dump() );
604 for ( const auto& langExt : docConfig.languagesExtensions.priorities )
605 cfg.setValue( "languages_extensions", langExt.first, langExt.second );
606 cfg.deleteKey( "files" );
607 if ( onlyIfNeeded ) {
608 IOStreamString stringFile;
609 cfg.writeStream( stringFile );
610 if ( !FileSystem::fileExists( cfg.path() ) ||
611 MD5::fromString( stringFile.getStream() ) != MD5::fromFile( cfg.path() ) ) {
612 FileSystem::fileWrite( cfg.path(), stringFile.getStream() );
613 }
614 } else {
615 cfg.writeFile();
616 }
617
618 if ( pluginManager ) {
619 std::string pluginsStatePath( projectsPath + "plugins_state" );
620 if ( !FileSystem::fileExists( pluginsStatePath ) &&
621 !FileSystem::makeDir( pluginsStatePath ) )
622 return;
623 std::string projectPluginsStatePath( pluginsStatePath + FileSystem::getOSSlash() +
624 hash.toHexString() );
625 if ( !FileSystem::fileExists( projectPluginsStatePath ) &&
626 !FileSystem::makeDir( projectPluginsStatePath ) )
627 return;
628 FileSystem::dirAddSlashAtEnd( projectPluginsStatePath );
629 pluginManager->forEachPlugin(

Callers

nothing calls this directly

Calls 15

fromStringFunction · 0.85
autoIndentToStringFunction · 0.85
findFunction · 0.85
setValueIMethod · 0.80
getFirstChildMethod · 0.80
getBaseLayoutMethod · 0.80
deleteKeyMethod · 0.80
writeStreamMethod · 0.80
writeFileMethod · 0.80
forEachPluginMethod · 0.80
forEachDocSharedPtrMethod · 0.80
getFilenameMethod · 0.80

Tested by

no test coverage detected