diff options
| author | ruki <[email protected]> | 2020-02-28 00:03:17 +0800 |
|---|---|---|
| committer | ruki <[email protected]> | 2020-02-27 18:19:44 +0800 |
| commit | 75e37c2f401c6547b417b157d7666dee293101e7 (patch) | |
| tree | 9f5ffb61758d0a4dbf7b2551f5b9e987074a2222 /core | |
| parent | 6410eefb86c5270e445d19fa92f26bcdace8f8cb (diff) | |
fix program file
Diffstat (limited to 'core')
| -rw-r--r-- | core/src/xmake/machine.c | 11 |
1 files changed, 11 insertions, 0 deletions
diff --git a/core/src/xmake/machine.c b/core/src/xmake/machine.c index f9a908c23..e3a584f49 100644 --- a/core/src/xmake/machine.c +++ b/core/src/xmake/machine.c @@ -500,7 +500,18 @@ static tb_bool_t xm_machine_get_program_directory(xm_machine_t* machine, tb_char tb_char_t programpath[TB_PATH_MAXN]; tb_long_t size = readlink(programfile, programpath, sizeof(programpath)); if (size >= 0 && size < sizeof(programpath)) + { programpath[size] = '\0'; + + // soft link to relative path? fix it + if (!tb_path_is_absolute(programpath)) + { + tb_char_t buff[TB_PATH_MAXN]; + tb_char_t const* rootdir = tb_path_directory(programfile, buff, sizeof(buff)); + if (rootdir && tb_path_absolute_to(rootdir, programpath, path, maxn)) // @note path and programfile are same buffer + tb_strlcpy(programpath, path, maxn); + } + } else tb_strlcpy(programpath, programfile, sizeof(programpath)); #else tb_char_t const* programpath = programfile; |
