Red Null
Red Null

Reputation: 143

Execute URL/Path in external program in Haxe

It is possible to run URL or path with external program from Haxe?

Something like a Process.Start("C:\") in C# will be opened drive C in file windows explorer (or Process.Start("/home/user/Desktop") will open Caja with this path in Linux Mint), or somethink like a package "Open" in NodeJS (it will do the same).

Or I need to open some text file with text editor, what selected in system by default. Or when I try to run URL, then must be opened default web-browser with this address.

Upvotes: 2

Views: 813

Answers (1)

Red Null
Red Null

Reputation: 143

I think I can do this little code:

public static function execUrl (url:String) : Void {
    switch (Sys.systemName()) {
        case "Linux", "BSD": Sys.command("xdg-open", [url]);
        case "Mac": Sys.command("open", [url]);
        case "Windows": Sys.command("start", [url]);
        default:
    }
}

in unix-like systems can be used program "xdg-open". it know how to run needed path/url, and in windows this can do program "start"

Upvotes: 4

Related Questions