Re: command line tool: processing files dropped on it?
Re: command line tool: processing files dropped on it?
- Subject: Re: command line tool: processing files dropped on it?
- From: Chris Hanson <email@hidden>
- Date: Wed, 01 Oct 2008 09:59:22 -0700
On Oct 1, 2008, at 3:46 AM, Barrie Green wrote:
I have a command line tool, written in c++, that I use on my windows
machine, which allows me to drop files onto it. Windows ensures the
tool receives the paths of the files dropped through the argc/argv
arguments in main.
I have ported my tool over to OS X using xcode and created a command
line tool and all my tests work OK.
But I'm hampered by the fact that finder won't let me drag n drop
files onto my tool! I can't even use it from the "Open With" Context
menu in finder.
Unlike Windows, on the Mac a command-line tool and an application are
conceptually different entities. You'll need to actually wrap your
tool in a proper bundle structure with an Info.plist and main nib
file. Your resulting application also will not be passed dropped/
opened files via argc and argv; instead, it will be sent events to
open the files which your application delegate will have to handle.
That said, it shouldn't be hard to create a simple wrapper application
around your command-line tool. In fact, there's example code on the
Apple Developer Connection web site that shows how to do this:
Moriarity
http://developer.apple.com/samplecode/Moriarity/index.html
I'm sure i've seen other (OS X) tools process files like this,
although I can't remember which.
Is there a way of getting this to work? Or is this just a difference
between platforms that requires a rewrite?
The latter, but it doesn't necessarily require a rewrite, just
wrapping an application around your command-line tool. You can even
keep them "physically" separate on disk, by putting the tool inside
your application's bundle structure and invoking it via NSTask as the
Moriarity example shows.
-- Chris
_______________________________________________
Cocoa-dev mailing list (email@hidden)
Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden