@@ -321,6 +321,38 @@ static bool r_core_project_load(RCore *core, const char *prj_name, const char *r
321321 const bool scr_prompt = r_config_get_b (core -> config , "scr.prompt" );
322322 (void ) load_project_rop (core , prj_name );
323323
324+ if (r_config_get_b (core -> config , "prj.new" )) {
325+ char * prj_dir = r_file_dirname (rcpath );
326+ char * prj_bin = prj_dir ? r_file_new (prj_dir , "prj.bin" , NULL ): NULL ;
327+ if (prj_bin && r_file_exists (prj_bin )) {
328+ bool ret = r_core_cmdf (core , "prj load %s" , prj_bin ) != -1 ;
329+ free (prj_bin );
330+ char * prj_path = prj_dir ;
331+ if (prj_path ) {
332+ Rvc * vc = rvc_open (prj_path , RVC_TYPE_GIT );
333+ core -> prj -> rvc = vc ;
334+ } else {
335+ R_LOG_ERROR ("Failed to load rvc" );
336+ }
337+ if (r_config_get_b (core -> config , "prj.history" )) {
338+ char * file = r_file_new (prj_path , "history" , NULL );
339+ r_line_hist_free (core -> cons -> line ); // R2_600 - hist_reset ?
340+ r_line_hist_load (core -> cons -> line , file );
341+ free (file );
342+ }
343+ free (prj_path );
344+ r_config_set_b (core -> config , "cfg.fortunes" , cfg_fortunes );
345+ r_config_set_b (core -> config , "scr.interactive" , scr_interactive );
346+ r_config_set_b (core -> config , "scr.prompt" , scr_prompt );
347+ r_config_bump (core -> config , "asm.arch" );
348+ r_config_set (core -> config , "prj.name" , prj_name );
349+ return ret ;
350+ }
351+ R_LOG_WARN ("Binary project '%s' not found; falling back to legacy script" , prj_bin ? prj_bin : "prj.bin" );
352+ free (prj_bin );
353+ free (prj_dir );
354+ }
355+
324356 // check if the target binary file exists before loading the project script
325357 char * rc_abspath = r_file_abspath (rcpath );
326358 char * rc_data = r_file_slurp (rc_abspath ? rc_abspath : rcpath , NULL );
0 commit comments