mirror of
https://gitee.com/RubyMetric/chsrc.git
synced 2025-12-25 20:52:49 +00:00
改进 xy_file_exist 的变量命名,修复内存泄露
This commit is contained in:
parent
b2a844b676
commit
437729a5cf
12
lib/xy.h
12
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;
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
|||
Loading…
Reference in New Issue