Cross Platform way to launch a system file or URL.

Bert Freudenberg bert at impara.de
Wed Dec 8 21:23:59 UTC 2004


Am 08.12.2004 um 19:18 schrieb oxe:

> Howdy Folks.
>
> We're developing a croquet app which does various things,
> among them is include views and references to files which
> are better viewed outside of croquet/squeak than in.
>
> I'd like to have a cross-platform method for running
> the OS's default viewer on files.
>
> For example,
> the Win32Shell method shellOpen: does this nicely.
> You pass it "c:\hello.txt" and it opens the file
> in notepad or whatever app the user has associated with .txt.
>
> Even better, you pass it "http://croquetproject.org",
> and it launches the user's preferred browser etc.
>
> Is there a class which can do the same thing,
> especially launching a URL,
> on mac & *nix as well ?

On Mac OS X you have the "open" command. Use FFI to implement the 
system() C lib function, then call system('open /path/to/my/file.txt'). 
You have to give a POSIX path. Works for URLs, too. See "man open".

- Bert -




More information about the Squeak-dev mailing list