• 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: Why is NSString->FSRef so hard?
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Why is NSString->FSRef so hard?


  • Subject: Re: Why is NSString->FSRef so hard?
  • From: Erg Consultant <email@hidden>
  • Date: Mon, 27 Apr 2009 22:05:55 -0700 (PDT)

BOOL                        result = YES;
    Boolean                        converted = false;
    unsigned                    i = 0;
    pid_t                        pid = -1;
    NSBundle                    *glBundle = [ NSBundle mainBundle ];
    NSDictionary                *d = nil;
    NSDictionary                *dd;
    NSString                    *z;
    NSString                    *zzz;
    NSMutableString                *m;
    NSArray                        *arr;
    NSURL                        *urlRef = nil;
    NSError                        *inError = nil;
    FSRef                        exeRef;
    LSApplicationParameters        inAppParams;
    ProcessSerialNumber            outPSN;
    OSStatus                    err = noErr;

    memset( &inAppParams, 0, sizeof( inAppParams ) );

    memset( &outPSN, 0, sizeof( outPSN ) );

    if( glBundle )
    {
        // Get main bundle info dict...

        d = [ glBundle infoDictionary ]
        if( d )
        {
            // Get the GL bundle's path from the info dict...

            z = [ d objectForKey:kNSBundleInitialPathInfoDictKey ];
            if( z )
            {
                // Break the path up into a path component array...

                arr = [ z componentsSeparatedByString:kSlashStringKey ];

                // Make a mutable path string to manipulate...

                m = [ NSMutableString stringWithCapacity:0 ];
            }
        }
    }

    if( m & arr )
    {
        for(i=0; i<[ arr count] - 1; i++ )
        {
            [m appendString:[arr objectAtIndex:i] ];
            [m appendString:@"/" ];
        }

        //go up one level to get at Info.plist

        [m appendString:@"Info.plist" ];

        dd = [ NSDictionary dictionaryWithContentsOfFile:m ];

        zzz = [ dd valueForKey:@"CFBundleExecutable" ];

        //reset

        [ m setString:@"" ];

        //Loop again appening all path compoents to final file to launch...

        for(i=0; i<[ arr count] - 1; i++ )
        {
            [m appendString:[arr objectAtIndex:i] ];
            [m appendString:@"/" ];
        }

        //now get full path to the file we want to actually run...

        [ m appendString:zzz ];

        [ m appendString:@".ifn" ];

        urlRef = [ NSURL fileURLWithPath:m ];
        if( urlRef )
        {
            CFShow( urlRef );

            converted = CFURLGetFSRef( (CFURLRef)urlRef, &exeRef );
            if( converted )
            {
                // Setup launch param block...

                inAppParams.application = &exeRef;

                // Launch!

                err = LSOpenApplication( &inAppParams, &outPSN );
                if( !err )
                {
                   err = GetProcessPID( &outPSN, &pid );
                    if( !err )
                    {
                        lppiProcInfo->dwProcessId = (DWORD)pid;

                        result = true;
                    }
                }
            }
        }



________________________________
From: Michael Ash <email@hidden>
To: cocoa-dev <email@hidden>
Sent: Monday, April 27, 2009 9:57:33 PM
Subject: Re: Why is NSString->FSRef so hard?

On Tue, Apr 28, 2009 at 12:51 AM, Erg Consultant
<email@hidden> wrote:
> So why isn't it working? Why does LSOpenApplication give me an error?

It is impossible to answer questions of this nature if you do not post
your code.

Mike
_______________________________________________

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

References: 
 >Why is NSString->FSRef so hard? (From: Erg Consultant <email@hidden>)
 >Re: Why is NSString->FSRef so hard? (From: "Sean McBride" <email@hidden>)
 >Re: Why is NSString->FSRef so hard? (From: Erg Consultant <email@hidden>)
 >Re: Why is NSString->FSRef so hard? (From: Ken Thomases <email@hidden>)
 >Re: Why is NSString->FSRef so hard? (From: Erg Consultant <email@hidden>)
 >Re: Why is NSString->FSRef so hard? (From: Michael Ash <email@hidden>)

  • Prev by Date: Re: Dockless app key bindings
  • Next by Date: Re: Why is NSString->FSRef so hard?
  • Previous by thread: Re: Why is NSString->FSRef so hard?
  • Next by thread: Re: Why is NSString->FSRef so hard?
  • Index(es):
    • Date
    • Thread