Re: Moving oneself to /Applications (or ~/Applications)
Re: Moving oneself to /Applications (or ~/Applications)
- Subject: Re: Moving oneself to /Applications (or ~/Applications)
- From: Jeremy Pereira <email@hidden>
- Date: Wed, 4 Mar 2009 11:37:51 +0000
If you really want to test whether an application is running from the
distribution dmg, I would have thought the easiest way is to put a
hidden file on the dmg in the same directory as the application bundle
and merely test for the existence of that hidden file at start up.
On 24 Feb 2009, at 02:34, Shawn Erickson wrote:
On Mon, Feb 23, 2009 at 6:22 PM, Tommy Nordgren
<email@hidden> wrote:
The following code will test if you are running from the DMG:
NSString * volName = @"Mother";
NSString * appName = @"MyApp.app";
if ([[[NSBundle mainBundle] bundlePath] isEqualTo: [ NSString
stringWithFormat:@"/Volumes/%@/%@",volName,appName]) {
//Here you can show an alert telling the user to to copy the
app to
the applications folder
}
If a disk image it mounted a second time (can happen in a few ways) it
won't be at /Volumes/Mother/... but at /Volumes/Mounter 1/... Also you
can mount disk images in location other then under /Volumes/...
If you really want to check this you should utilize
DiskImages.framework (IIRC) or possibly use "hdutil info -plist" and
look for your disk image and its current mount location. Then compare
that to your bundles location.
-Shawn
For example...
MacPro:~ shawnce$ hdiutil info -plist
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN"
"http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>framework</key>
<string>195.2.2</string>
<key>images</key>
<array>
<dict>
<key>autodiskmount</key>
<true/>
<key>blockcount</key>
<integer>1138724</integer>
<key>blocksize</key>
<integer>512</integer>
<key>hdid-pid</key>
<integer>7098</integer>
<key>icon-path</key>
<string>/System/Library/PrivateFrameworks/DiskImages.framework/
Resources/CDiskImage.icns</string>
<key>image-alias</key>
<data>
AAAAAAFuAAIAAARNYWluAAAAAAAAAAAAAAAAAAAAAAAAAAAAAADD
STB4SCsAAAADpvcQaVdvcmswOVRyaWFsLmRtZwAAAAAAAAAAAAAA
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAMSJ
7MWHd2YAAAAAAAAAAP////8AAAkgAAAAAAAAAAAAAAAAAAAACURv
d25sb2FkcwAAEAAIAADDSZLoAAAAEQAIAADFh+fmAAAAAQAMAAOm
9wADClAAAHmMAAIALU1haW46VXNlcnM6c2hhd25jZTpEb3dubG9h
ZHM6aVdvcmswOVRyaWFsLmRtZwAADgAiABAAaQBXAG8AcgBrADAA
OQBUAHIAaQBhAGwALgBkAG0AZwAPAAoABABNAGEAaQBuABIAKFVz
ZXJzL3NoYXduY2UvRG93bmxvYWRzL2lXb3JrMDlUcmlhbC5kbWcA
EwABLwAAFQACAA7//wAA
</data>
<key>image-encrypted</key>
<false/>
<key>image-path</key>
<string>/Users/shawnce/Downloads/iWork09Trial.dmg</string>
<key>image-type</key>
<string>UDIF read-only compressed (zlib)</string>
<key>owner-uid</key>
<integer>501</integer>
<key>removable</key>
<true/>
<key>system-entities</key>
<array>
<dict>
<key>content-hint</key>
<string>Apple_partition_scheme</string>
<key>dev-entry</key>
<string>/dev/disk7</string>
</dict>
<dict>
<key>content-hint</key>
<string>Apple_partition_map</string>
<key>dev-entry</key>
<string>/dev/disk7s1</string>
</dict>
<dict>
<key>content-hint</key>
<string>Apple_Driver_ATAPI</string>
<key>dev-entry</key>
<string>/dev/disk7s2</string>
</dict>
<dict>
<key>content-hint</key>
<string>Apple_HFS</string>
<key>dev-entry</key>
<string>/dev/disk7s3</string>
<key>mount-point</key>
<string>/Volumes/iWork '09 Trial Install DVD</string>
</dict>
</array>
<key>writeable</key>
<false/>
</dict>
</array>
<key>revision</key>
<string>10.5v195.2.2</string>
<key>vendor</key>
<string>Apple</string>
</dict>
</plist>
_______________________________________________
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
_______________________________________________
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