From a2ce1fdd5ef7624039e5c5407d3167d4988f4291 Mon Sep 17 00:00:00 2001 From: Cameron Taylor Date: Thu, 23 Nov 2023 19:54:34 -0500 Subject: [PATCH] opening and selecting specific file --- source/funkin/util/WindowUtil.hx | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/source/funkin/util/WindowUtil.hx b/source/funkin/util/WindowUtil.hx index 891bb39f8..9f623c39d 100644 --- a/source/funkin/util/WindowUtil.hx +++ b/source/funkin/util/WindowUtil.hx @@ -53,6 +53,26 @@ class WindowUtil #end } + /** + * Runs platform-specific code to open a file explorer and select a specific file. + * @param targetPath The path of the file to select. + */ + public static function openSelectFile(targetPath:String):Void + { + #if CAN_OPEN_LINKS + #if windows + Sys.command('explorer', ["/select," + targetPath.replace("/", "\\")]); + #elseif mac + Sys.command('open', ["-R", targetPath]); + #elseif linux + // TODO: unsure of the linux equivalent to opening a folder and then "selecting" a file. + Sys.command('open', [targetPath]); + #end + #else + throw 'Cannot open URLs on this platform.'; + #end + } + /** * Dispatched when the game window is closed. */