On Mon, Feb 23, 2009 at 6:22 PM, Tommy Nordgren
<tommy.nordg...@comhem.se> 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 (Cocoa-dev@lists.apple.com)

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:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com

Reply via email to