Re: Problem opening file
Re: Problem opening file
- Subject: Re: Problem opening file
- From: Sherm Pendley <email@hidden>
- Date: Tue, 22 Feb 2011 11:14:58 -0500
On Tue, Feb 22, 2011 at 10:47 AM, Carlos Eduardo Mello
<email@hidden> wrote:
>
> I have a configuration file which is used by an internal library in my app's
> data model engine. The engine was written in c++ and needs this file for
> loading the app's documents correctly. Theis file never changes and
> shouldn't have to be seen or open by the user. Its contents are the same
> for any document files oppened by the user.
>
> During debugging I place the file next to the executable in Build->Debug and
> the library opens it with using c++ streams with just the file name.
> However, when I compilethe app as release, and place the configuration file
> next to the executable, it fails to find the file.
It's not a Debug/Release difference. The difference is how you're
launching your app - the current working directory is different when
you launch the app from Finder, from Xcode, and using the "open"
command-line tool.
> I imagine I have to deal
> with application bundle api, but the thing is I can't add any cocoa code to
> this library, as it needs remain cross-platform.
Does this library allow you to specify the full path to its config
file, instead of just its name, when you initialize the library? If
so, you could keep the platform-specific code outside of the library
itself.
Alternatively, you could use NSBundle methods to find the location of
your executable, then chdir() to that directory before initializing
the library.
sherm--
--
Cocoa programming in Perl:
http://camelbones.sourceforge.net
_______________________________________________
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