From 437729a5cfe5b757cf628afaf234dfa0c3a399c3 Mon Sep 17 00:00:00 2001 From: Mikachu2333 Date: Mon, 6 Oct 2025 01:54:13 +0800 Subject: [PATCH] =?UTF-8?q?=E6=94=B9=E8=BF=9B=20xy=5Ffile=5Fexist=20?= =?UTF-8?q?=E7=9A=84=E5=8F=98=E9=87=8F=E5=91=BD=E5=90=8D=EF=BC=8C=E4=BF=AE?= =?UTF-8?q?=E5=A4=8D=E5=86=85=E5=AD=98=E6=B3=84=E9=9C=B2?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- lib/xy.h | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/lib/xy.h b/lib/xy.h index 66316b4..4582631 100644 --- a/lib/xy.h +++ b/lib/xy.h @@ -1164,13 +1164,19 @@ _xy_win_powershellv5_profile () static bool xy_file_exist (const char *path) { - const char *new_path = path; + char *expanded_path = NULL; + const char *check_path = path; + if (xy_str_start_with (path, "~")) { - new_path = xy_2strcat (xy_os_home, path + 1); + expanded_path = xy_2strcat (xy_os_home, path + 1); + check_path = expanded_path; } + // 0 即 F_OK - return (0==access (new_path, 0)) ? true : false; + bool result = (0 == access (check_path, 0)) ? true : false; + if (expanded_path) free (expanded_path); + return result; } /**