model_server/project/src/proj_save.cxx
// Returns 0 on success
//        -1 on failure
//  proj_set - set of projects with pmods for future saving
Returns 0 on success
1 on failure
proj_set - set of projects with pmods for future saving
Returns 0 on success 1 on failure proj_set - set of projects with pmods for future saving
int proj_save_recursive (projNode *prj, int lvl, FILE *prj_file, int *info, objArr& pmod_projs)
{
    Initialize(proj_save_recursive__projNode*_int_FILE*_int*_objArr&);
    genString cur_txt;
    int ret_path = 0;
    int res = proj_get_text_to_save (prj, lvl, cur_txt);
    if (res != 0)
	return -1;
    res = fwrite ((char *)cur_txt, cur_txt.length(), 1, prj_file);
    if (res != 1)
	return -1;
    if (is_disbuild_cache()) 
	disbuild_cache_project (prj, cur_txt);
    if (prj->visited() == 0) {
	if (prj->pmod_type == PMOD_PDF || proj_has_real_xref(prj)) {
	    pmod_projs.insert(prj);
	}
	if (prj->is_script())
	    prj->force_refresh( 1 );
	else
	    prj->refresh();
    }
    info[PRJ]++;
    lvl++;
    info[LVL] = (lvl > info[LVL]) ? lvl : info[LVL];
    symbolArr& proj_contents = prj->rtl_contents();
    symbolPtr sym;
    ForEachS(sym, proj_contents) {
        if (sym.get_kind() == DD_MODULE) {
	    projModule *mod = checked_cast(projModule,sym);
	    res = proj_get_text_to_save (mod, lvl, cur_txt);
	    if (res == 0) {
		res = fwrite ((char *)cur_txt, cur_txt.length(), 1, prj_file);
		if (is_disbuild_cache())
		    disbuild_cache_module (mod, cur_txt);
		if (res == 1)
		    info[MOD]++;
		else {
		    ret_path = -1;
		    break;
		}
	    }
	} else if (sym.get_kind() == DD_PROJECT) {
            appPtr app_head = sym.get_def_app();
            if(app_head && is_projHeader(app_head)) {
                projNode *nd = projNodePtr(app_head->get_root());
		ret_path     = proj_save_recursive (nd, lvl, prj_file, info, pmod_projs);
		if (ret_path != 0)
		   break;
	    }
	}
    }
    return ret_path;
}
int proj_save_recursive ( projNode * prj , int lvl , FILE * prj_file , int * info , objArr & pmod_projs ) { Initialize ( proj_save_recursive__projNode * _int_FILE * _int * _objArr & ) ; genString cur_txt ; int ret_path = 0 ; int res = proj_get_text_to_save ( prj , lvl , cur_txt ) ; if ( res != 0 ) return -1 ; res = fwrite ( ( char * ) cur_txt , cur_txt . length ( ) , 1 , prj_file ) ; if ( res != 1 ) return -1 ; if ( is_disbuild_cache ( ) ) disbuild_cache_project ( prj , cur_txt ) ; if ( prj -> visited ( ) == 0 ) { if ( prj -> pmod_type == PMOD_PDF || proj_has_real_xref ( prj ) ) { pmod_projs . insert ( prj ) ; } if ( prj -> is_script ( ) ) prj -> force_refresh ( 1 ) ; else prj -> refresh ( ) ; } info [ PRJ ] ++ ; lvl ++ ; info [ LVL ] = ( lvl > info [ LVL ] ) ? lvl : info [ LVL ] ; symbolArr & proj_contents = prj -> rtl_contents ( ) ; symbolPtr sym ; ForEachS ( sym , proj_contents ) { if ( sym . get_kind ( ) == DD_MODULE ) { projModule * mod = checked_cast ( projModule , sym ) ; res = proj_get_text_to_save ( mod , lvl , cur_txt ) ; if ( res == 0 ) { res = fwrite ( ( char * ) cur_txt , cur_txt . length ( ) , 1 , prj_file ) ; if ( is_disbuild_cache ( ) ) disbuild_cache_module ( mod , cur_txt ) ; if ( res == 1 ) info [ MOD ] ++ ; else { ret_path = -1 ; break ; } } } else if ( sym . get_kind ( ) == DD_PROJECT ) { appPtr app_head = sym . get_def_app ( ) ; if ( app_head && is_projHeader ( app_head ) ) { projNode * nd = projNodePtr ( app_head -> get_root ( ) ) ; ret_path = proj_save_recursive ( nd , lvl , prj_file , info , pmod_projs ) ; if ( ret_path != 0 ) break ; } } } return ret_path ; }
Returns 0 on success
1 on failure
proj_set - set of projects with pmods for future saving
Returns 0 on success 1 on failure proj_set - set of projects with pmods for future saving
// boris: 971008, takes care about projects with scripts [[ ... ]]