• 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: Tue, 28 Apr 2009 00:37:30 -0700 (PDT)

Yes, I've verified that everything is correct. I zero'ed the launch param block and set kLSLaunchDefaults.

Oddly, I can now get it to work in the built release version (binary) but if I run it from the debugger, LSOpenApplication returns noErr, but if I try to get the pid of the launched, process, it says not found + the binary itself never runs (even though LSOpenApplication returns no err). I assume this has something to do with XCode launching it within its own process. What a headache!

Erg




________________________________
From: Chris Hanson <email@hidden>
To: Erg Consultant <email@hidden>
Cc: email@hidden
Sent: Tuesday, April 28, 2009 12:22:38 AM
Subject: Re: Why is NSString->FSRef so hard?

On Apr 27, 2009, at 9:14 PM, Erg Consultant wrote:

> I write the original STL string to a tmp file, then read it back in. The file is encoded in MacRoman. I tried UTF8 with both converting and reinterpreting but if I use UTF8 when I read it back from file, the read returns nil. If I use MacRoman, the string reads back fine, but when I go to convert it to the URL and then the FSSpec, the FSSpec is invalid and cannot be used byLSOpenApplication

I think the confusion in your code about encodings is part of the problem: Why is anything MacRoman to begin with at all?  Applications these days should be using Unicode throughout if at all possible.

> Here are the snippets:
>
> exePathString = [ NSString stringWithContentsOfFile:kTempQuagmireHackFilePathNSString
>                                encoding:NSMacOSRomanStringEncoding
>                                error:&inError ];    // <- Works
>
> ....
>
> urlRef = [ NSURL fileURLWithPath:exePathString ]; // <- Works
>
> converted = CFURLGetFSRef( (CFURLRef)urlRef, &exeRef ); // <- Works

It's important to know that this really works -- that CFURLGetFSRef is returning true -- because an FSRef can't refer to a non-existent file.  Does it?

If you use -[NSData dataWithContentsOfURL:options:error:] to read the contents of your URL, does that succeed?  Or if it fails, what does it return for its error output parameter?

> inAppParams.application = &exeRef; // I also zero out the whole block before this.
>
> err = LSOpenApplication( &inAppParams, &outPSN ); // <- Fails with -10810 error - Unexpected internal error

What else do you have set in inAppParams?  Did you specify kLSLaunchDefaults (which *is not* 0) for inAppParams.flags?

Do you have appropriate permissions for the application at your ultimate FSRef?

  -- 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

References: 
 >Re: Why is NSString->FSRef so hard? (From: Steve Christensen <email@hidden>)
 >Re: Why is NSString->FSRef so hard? (From: Erg Consultant <email@hidden>)
 >Re: Why is NSString->FSRef so hard? (From: Chris Hanson <email@hidden>)

  • Prev by Date: Re: Scheduling application
  • Next by Date: Re: Float value change
  • Previous by thread: Re: Why is NSString->FSRef so hard?
  • Next by thread: Re: Why is NSString->FSRef so hard?
  • Index(es):
    • Date
    • Thread