Re: Why is NSString->FSRef so hard?
Re: Why is NSString->FSRef so hard?
- Subject: Re: Why is NSString->FSRef so hard?
- From: Chris Hanson <email@hidden>
- Date: Tue, 28 Apr 2009 00:22:38 -0700
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