* make sure an url mime type is registered before using it.
* lines and cols are 1-based. git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@23959 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
parent
75fda7bdc7
commit
608aae69a1
|
@ -85,15 +85,17 @@ main(int argc, char **argv)
|
|||
// try to open it as an URI
|
||||
BString mimeType = "application/x-vnd.Be.URL.";
|
||||
BString arg(*argv);
|
||||
if (arg.FindFirst("://") >= 0)
|
||||
mimeType.Append(arg, arg.FindFirst("://"));
|
||||
else
|
||||
mimeType.Append(arg, arg.FindFirst(":"));
|
||||
mimeType.Append(arg, arg.FindFirst(":"));
|
||||
|
||||
char *args[2] = { *argv, NULL };
|
||||
status = be_roster->Launch(openWith ? openWith : mimeType.String(), 1, args);
|
||||
if (status == B_OK)
|
||||
continue;
|
||||
// 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;
|
||||
}
|
||||
|
||||
// maybe it's "file:line" or "file:line:col"
|
||||
int line = 0, col = 0, i;
|
||||
|
@ -109,7 +111,7 @@ main(int argc, char **argv)
|
|||
|
||||
status = entry.SetTo(arg.String());
|
||||
if (status == B_OK && entry.Exists())
|
||||
status = open_file(openWith, entry, line - 1, col - 1);
|
||||
status = open_file(openWith, entry, line);
|
||||
if (status == B_OK)
|
||||
continue;
|
||||
|
||||
|
@ -121,7 +123,7 @@ main(int argc, char **argv)
|
|||
|
||||
status = entry.SetTo(arg.String());
|
||||
if (status == B_OK && entry.Exists())
|
||||
status = open_file(openWith, entry, line - 1, col - 1);
|
||||
status = open_file(openWith, entry, line, col);
|
||||
}
|
||||
} else
|
||||
status = B_ENTRY_NOT_FOUND;
|
||||
|
|
Loading…
Reference in New Issue