Pixel-Composer/scripts/shell_functions/shell_functions.gml

53 lines
1.3 KiB
Plaintext
Raw Normal View History

function shellOpenExplorer(path) {
2023-12-13 11:09:06 +01:00
if(OS == os_windows) {
var _windir = environment_get_variable("WINDIR") + "/explorer.exe";
path = string_replace_all(path, "/", "\\");
shell_execute_async(_windir, path);
2023-12-13 11:09:06 +01:00
} else if(OS == os_macosx) {
path = string_replace_all(path, "\\", "/");
var res = shell_execute_async("open", path);
}
2024-05-03 09:02:18 +02:00
return 0;
}
2023-09-28 13:15:29 +02:00
function shell_execute(path, command, ref = noone, _log = true) {
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);
if(_log) print($"Execute {path} {command} | {res}");
return res;
}
2023-11-01 08:10:25 +01:00
function shell_execute_async(path, command, ref = noone, _log = true) {
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
function env_user() {
2023-12-13 11:09:06 +01:00
INLINE
if(OS == os_windows) return string(environment_get_variable("userprofile")) + "/AppData/Local/PixelComposer/";
2023-12-13 11:09:06 +01:00
if(OS == os_macosx) return string(environment_get_variable("HOME")) + "/PixelComposer/";
return "";
}