mirror of
https://github.com/RubyMetric/chsrc
synced 2025-06-28 15:32:46 +08:00
Add powershell profile location
This commit is contained in:
parent
9b2a662f26
commit
e9cd2a327f
@ -72,5 +72,7 @@ main (int argc, char const *argv[])
|
|||||||
xy_error("错误:输出错误内容");
|
xy_error("错误:输出错误内容");
|
||||||
|
|
||||||
putb(xy_file_exist("chsrc.png"));
|
putb(xy_file_exist("chsrc.png"));
|
||||||
|
putb(xy_file_exist(xy_win_powershell_profile));
|
||||||
|
putb(xy_file_exist(xy_win_powershellv5_profile));
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
31
xy.h
31
xy.h
@ -494,6 +494,34 @@ xy_getcmd(const char * cmd, bool (*func)(const char*))
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
#define xy_os_home _xy_os_home()
|
||||||
|
char*
|
||||||
|
_xy_os_home ()
|
||||||
|
{
|
||||||
|
char* home = NULL;
|
||||||
|
if (xy_on_windows)
|
||||||
|
home = getenv("USERPROFILE");
|
||||||
|
else
|
||||||
|
home = getenv("HOME");
|
||||||
|
return home;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
#define xy_win_powershell_profile _xy_win_powershell_profile()
|
||||||
|
#define xy_win_powershellv5_profile _xy_win_powershellv5_profile()
|
||||||
|
char*
|
||||||
|
_xy_win_powershell_profile ()
|
||||||
|
{
|
||||||
|
return xy_2strjoin(xy_os_home, "\\Documents\\PowerShell\\Microsoft.PowerShell_profile.ps1");
|
||||||
|
}
|
||||||
|
|
||||||
|
char*
|
||||||
|
_xy_win_powershellv5_profile()
|
||||||
|
{
|
||||||
|
return xy_2strjoin(xy_os_home, "\\Documents\\WindowsPowerShell\\Microsoft.PowerShell_profile.ps1");
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @note Windows上,`path` 不要夹带变量名,因为最终 access() 不会帮你转换
|
* @note Windows上,`path` 不要夹带变量名,因为最终 access() 不会帮你转换
|
||||||
*/
|
*/
|
||||||
@ -503,9 +531,8 @@ xy_file_exist(char* path)
|
|||||||
char* newpath = path;
|
char* newpath = path;
|
||||||
if (xy_on_windows)
|
if (xy_on_windows)
|
||||||
{
|
{
|
||||||
char* home = getenv("USERPROFILE");
|
|
||||||
if (xy_str_start_with(path, "~")) {
|
if (xy_str_start_with(path, "~")) {
|
||||||
newpath = xy_2strjoin(home, path+1);
|
newpath = xy_2strjoin(xy_os_home, path+1);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return access(newpath, 0) ? false : true;
|
return access(newpath, 0) ? false : true;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user