• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: launching 2 same applications
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: launching 2 same applications


  • Subject: Re: launching 2 same applications
  • From: "M. Uli Kusterer" <email@hidden>
  • Date: Wed, 8 Oct 2003 20:38:19 +0200

At 18:00 Uhr +0000 08.10.2003, Sean Liong wrote:
I am writing an application for a usb mass storage flash storage device. The application cannot be launch on the usb device itself where some of the functions won't allow. So I need to ensure that the application will only run on a specific path and not on the device itself.

so any suggestion?

Okay, that's something entirely different than ensuring your app is always in the Applications folder. The only thing you want to do is find out whether your application is residing on the device it is currently controlling. Am I understanding this correctly?

Well, in that case, [[NSBundle mainBundle] bundlePath] will, as already said, give you the path to your bundle. From there on, you'll have to find out what device this path is on. This depends on your USB mass storage device. If this application works with this device, I suppose you have some sort of path to the device, or a driver name, or something like that?

If you had a path to the root level of the device (like /Volumes/MyUSBDevice/), you could simply do a string compare on the two paths, and voila, you'd know whether the file's on the device.

Otherwise, you'd probably have to mess with some Unix (BSD? POSIX?) API, or talk to the driver directly. That's not really my area of expertise, but I'm sure that there's some Darwin newsgroup or mailing list where you can find out about these Unix APIs if no Unix guru here can help you.

Once you have done that, you know whether the copy of the app being launched is on the USB device, you can react by putting up a dialog and telling the user. If you want to be so polite as to offer the user the option of opening a copy of your app that already resides on the hard disk, you could use LaunchServices to locate your application (LSFindApplicationForInfo in CoreServices.framework). NSWorkspace apparently only looks in "the standard locations" (I guess that means /Applications and ~/Applications), but LSFindApplicationForInfo should do the trick nicely if you use the bundle identifier to look up the app.
--
Cheers,
M. Uli Kusterer
------------------------------------------------------------
"The Witnesses of TeachText are everywhere..."
http://www.zathras.de
_______________________________________________
cocoa-dev mailing list | email@hidden
Help/Unsubscribe/Archives: http://www.lists.apple.com/mailman/listinfo/cocoa-dev
Do not post admin requests to the list. They will be ignored.
References: 
 >Re: launching 2 same applications (From: "Sean Liong" <email@hidden>)

  • Prev by Date: Re: launching 2 same applications
  • Next by Date: DO: Setting Protocol before leaving server...
  • Previous by thread: Re: launching 2 same applications
  • Next by thread: Re: launching 2 same applications
  • Index(es):
    • Date
    • Thread