From 1104b1b0f69582e0d5884130dd54aa8176ddaf2a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Axel=20D=C3=B6rfler?= Date: Tue, 25 Feb 2003 18:00:40 +0000 Subject: [PATCH] Added my "open" command to the repository. git-svn-id: file:///srv/svn/repos/haiku/trunk/current@2847 a95241bf-73f2-0310-859d-f6bbb57e9c96 --- src/apps/bin/Jamfile | 1 + src/apps/bin/open.cpp | 55 +++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 56 insertions(+) create mode 100644 src/apps/bin/open.cpp diff --git a/src/apps/bin/Jamfile b/src/apps/bin/Jamfile index e2f8716c03..c76dfa473b 100644 --- a/src/apps/bin/Jamfile +++ b/src/apps/bin/Jamfile @@ -11,6 +11,7 @@ StdBinCommands listattr.cpp lsindex.cpp modifiers.cpp + open.cpp quit.cpp setversion.cpp shutdown.cpp diff --git a/src/apps/bin/open.cpp b/src/apps/bin/open.cpp new file mode 100644 index 0000000000..c8127abf92 --- /dev/null +++ b/src/apps/bin/open.cpp @@ -0,0 +1,55 @@ +/* Launches an application/document from the shell +** +** Copyright 2003, Axel Dörfler, axeld@pinc-software.de. All rights reserved. +** Distributed under the terms of the OpenBeOS License. +*/ + +#include +#include +#include + +#include +#include +#include + + +int +main(int argc, char **argv) +{ + char *progName = argv[0]; + if (strrchr(progName, '/')) + progName = strrchr(progName, '/') + 1; + + if (argc < 2) + fprintf(stderr,"usage: %s ...\n", progName); + + BRoster roster; + + while (*++argv) { + status_t rc; + + BEntry entry(*argv); + if ((rc = entry.InitCheck()) == B_OK && entry.Exists()) { + entry_ref ref; + entry.GetRef(&ref); + + BMessenger tracker("application/x-vnd.Be-TRAK"); + if (tracker.IsValid()) { + BMessage message(B_REFS_RECEIVED); + message.AddRef("refs", &ref); + + tracker.SendMessage(&message); + } else + rc = roster.Launch(&ref); + } else if (!strncasecmp("application/", *argv, 12)) { + // maybe it's an application-mimetype? + rc = roster.Launch(*argv); + } else if (rc == B_OK) + rc = B_ENTRY_NOT_FOUND; + + if (rc != B_OK) + fprintf(stderr, "%s: \"%s\": %s\n", progName, *argv, strerror(rc)); + } + + return 0; +}