Pixel-Composer/scripts/shell_functions/shell_functions.gml

50 lines
1.4 KiB
Plaintext
Raw Normal View History

2023-12-13 11:09:06 +01:00
function shellOpenExplorer(path) { #region
if(OS == os_windows) {
var _windir = environment_get_variable("WINDIR") + "/explorer.exe";
path = string_replace_all(path, "/", "\\");
shell_execute_async(_windir, path);
} else if(OS == os_macosx) {
path = string_replace_all(path, "\\", "/");
var res = shell_execute_async("open", path);
}
} #endregion
2023-09-28 13:15:29 +02:00
2023-12-13 11:09:06 +01:00
function shell_execute(path, command, ref = noone) { #region
2023-11-08 08:38:04 +01:00
INLINE
2023-09-28 13:15:29 +02:00
2023-12-15 12:56:36 +01:00
if(OS == os_macosx) {
path = string_replace_all(path, "\\", "/");
command = string_replace_all(command, "\\", "/");
}
2023-09-28 13:15:29 +02:00
var txt = $"{path} {command}";
2023-12-13 11:09:06 +01:00
var res = ProcessExecute(txt);
2023-12-15 12:56:36 +01:00
print($"Execute {path} {command} | {res}");
return res;
2023-12-13 11:09:06 +01:00
} #endregion
2023-11-01 08:10:25 +01:00
function shell_execute_async(path, command, ref = noone, _log = true) { #region
2023-11-08 08:38:04 +01:00
INLINE
2023-11-01 08:10:25 +01:00
2024-02-12 13:59:43 +01:00
if(IS_CMD) return shell_execute(path, command, ref);
2023-12-15 12:56:36 +01:00
if(OS == os_macosx) {
path = string_replace_all(path, "\\", "/");
command = string_replace_all(command, "\\", "/");
}
2023-11-01 08:10:25 +01:00
var txt = $"{path} {command}";
2023-12-13 11:09:06 +01:00
var res = ProcessExecuteAsync(txt);
if(_log) print($"Execute async {path} {command} | {res}");
return res;
2023-12-13 11:09:06 +01:00
} #endregion
function env_user() { #region
INLINE
if(OS == os_windows) return string(environment_get_variable("userprofile")) + "\\AppData\\Local\\PixelComposer\\";
if(OS == os_macosx) return string(environment_get_variable("HOME")) + "/PixelComposer/";
return "";
} #endregion