Make windows recognize ~

This commit is contained in:
Aoran Zeng 2023-09-27 15:54:23 +08:00
parent f65793c1db
commit 720f011c6e
2 changed files with 5 additions and 1 deletions

View File

@ -295,7 +295,7 @@ pl_php_setsrc (char* option)
void void
pl_lua_getsrc (char* option) pl_lua_getsrc (char* option)
{ {
chsrc_check_file (" ~/.luarocks/config.lua"); chsrc_check_file ("~/.luarocks/config.lua");
chsrc_check_file ("~/.luarocks/upload_config.lua"); chsrc_check_file ("~/.luarocks/upload_config.lua");
} }

View File

@ -290,6 +290,10 @@ chsrc_check_file (const char* path)
{ {
char* cmd = NULL; char* cmd = NULL;
if(xy_on_windows) { if(xy_on_windows) {
if (xy_str_start_with(path, "~/")){
path = xy_2strjoin("%USERPROFILE%\\", xy_str_delete_prefix(path, "~/"));
path = xy_str_gsub(path, "/", "\\");
}
cmd = xy_2strjoin ("type ", path); cmd = xy_2strjoin ("type ", path);
} else { } else {
cmd = xy_2strjoin ("cat ", path); cmd = xy_2strjoin ("cat ", path);