Accepts URLs as command line arguments.

Fixes #9793

Signed-off-by: Kacper Kasper <kacperkasper@gmail.com>
This commit is contained in:
Owen 2017-12-03 23:51:07 +00:00 committed by Kacper Kasper
parent da9188ac28
commit 9e53d4e91b

View File

@ -229,9 +229,19 @@ MainApp::ArgvReceived(int32 argc, char** argv)
char cwd[B_PATH_NAME_LENGTH];
getcwd(cwd, sizeof(cwd));
BMessage message(B_REFS_RECEIVED);
for (int i = 1; i < argc; i++) {
BUrl url(argv[i]);
if (url.IsValid()) {
BMessage archivedUrl;
url.Archive(&archivedUrl);
BMessage msg(M_URL_RECEIVED);
if (msg.AddMessage("mediaplayer:url", &archivedUrl) == B_OK)
RefsReceived(&msg);
continue;
}
BPath path;
if (argv[i][0] != '/')
path.SetTo(cwd, argv[i]);
@ -241,13 +251,11 @@ MainApp::ArgvReceived(int32 argc, char** argv)
if (!entry.Exists() || !entry.IsFile())
continue;
BMessage message(B_REFS_RECEIVED);
entry_ref ref;
if (entry.GetRef(&ref) == B_OK)
message.AddRef("refs", &ref);
if (entry.GetRef(&ref) == B_OK && message.AddRef("refs", &ref) == B_OK)
RefsReceived(&message);
}
if (message.HasRef("refs"))
RefsReceived(&message);
}