@@ -654,7 +654,7 @@ static tb_bool_t xm_engine_save_arguments(xm_engine_t* engine, tb_int_t argc, tb
654
654
return tb_true ;
655
655
}
656
656
657
- static tb_size_t xm_engine_get_program_file (xm_engine_t * engine , tb_char_t * path , tb_size_t maxn )
657
+ static tb_size_t xm_engine_get_program_file (xm_engine_t * engine , tb_char_t * * argv , tb_char_t * path , tb_size_t maxn )
658
658
{
659
659
// check
660
660
tb_assert_and_check_return_val (engine && path && maxn , tb_false );
@@ -745,6 +745,14 @@ static tb_size_t xm_engine_get_program_file(xm_engine_t* engine, tb_char_t* path
745
745
}
746
746
#endif
747
747
748
+ tb_char_t const * p = argv ? argv [0 ] : tb_null ;
749
+ if (p && tb_file_info (p , tb_null ))
750
+ {
751
+ tb_strlcpy (path , p , maxn );
752
+ ok = tb_true ;
753
+ break ;
754
+ }
755
+
748
756
} while (0 );
749
757
750
758
// ok?
@@ -1452,7 +1460,7 @@ tb_int_t xm_engine_main(xm_engine_ref_t self, tb_int_t argc, tb_char_t** argv, t
1452
1460
if (!xm_engine_get_project_directory (engine , path , sizeof (path ))) return -1 ;
1453
1461
1454
1462
// get the program file
1455
- if (!xm_engine_get_program_file (engine , path , sizeof (path ))) return -1 ;
1463
+ if (!xm_engine_get_program_file (engine , argv , path , sizeof (path ))) return -1 ;
1456
1464
1457
1465
// get the program directory
1458
1466
if (!xm_engine_get_program_directory (engine , path , sizeof (path ), path )) return -1 ;
0 commit comments