diff --git a/src/bin/open.cpp b/src/bin/open.cpp index 3ba076eeeb..86108e6adf 100644 --- a/src/bin/open.cpp +++ b/src/bin/open.cpp @@ -1,22 +1,25 @@ /* * Copyright 2003-2007, Axel Dörfler, axeld@pinc-software.de. * Copyright 2005-2007, François Revol, revol@free.fr. + * Copyright 2009, Jonas Sundström, jonas@kirilla.com. * All rights reserved. Distributed under the terms of the MIT License. */ /*! Launches an application/document from the shell */ +#include +#include +#include +#include + #include #include #include #include #include -#include -#include -#include -#include +#include const char *kTrackerSignature = "application/x-vnd.Be-TRAK"; @@ -86,25 +89,15 @@ main(int argc, char **argv) status = B_OK; } else if (strchr(*argv, ':')) { // try to open it as an URI - BString mimeType = "application/x-vnd.Be.URL."; - BString arg(*argv); - mimeType.Append(arg, arg.FindFirst(":")); - - // the protocol should be alphanum - // we just check if it's registered - // if not there is likely no supporting app anyway - if (BMimeType::IsValid(mimeType.String())) { - char *args[2] = { *argv, NULL }; - status = be_roster->Launch(openWith ? openWith - : mimeType.String(), 1, args); - if (status == B_OK) - continue; - } + BPrivate::Support::BUrl url(*argv); + if (url.OpenWithPreferredApplication() == B_OK) + continue; // maybe it's "file:line" or "file:line:col" int line = 0, col = 0, i; status = B_ENTRY_NOT_FOUND; // remove gcc error's last : + BString arg(*argv); if (arg[arg.Length() - 1] == ':') arg.Truncate(arg.Length() - 1);