Talk About Network

Google





Mac > Mac Programmer Help > Re: Strange fop...
Latest [ Topics | Posts ] Archive Post A New Topic Post a Reply
<< Topic < Post Post 2 of 4 Topic 3734 of 3889
Post > Topic >>

Re: Strange fopen error

by mayoneez <mikko.oksalahti@[EMAIL PROTECTED] > May 6, 2008 at 11:49 PM

On May 7, 9:24=A0am, mayoneez <mikko.oksala...@[EMAIL PROTECTED]
> wrote:
> I have a Carbon application and am experiencing a strange error with
> fopen.
>
> First time I open the file with fopen, it succeeds. I then close the
> file with fclose.
>
> But when I try to open the same file the second time (using the same
> code), it fails with errno =3D=3D 2. Also, if I try to open a different
> file, it fails. Only the first fopen succeeds.
>
> Any ideas? Here's the relevant code fragment:
>
> =A0 char filename[256];
> =A0 sprintf(filename, "./level%d.txt", m_current_level + 1);
> =A0 FILE* fp =3D fopen(filename, "r");
> =A0 if(fp) {
> =A0 =A0 ...
> =A0 =A0 fclose(fp);
> =A0 }
>
> I've debugged and filename is correct on the second time, as well.
>
> Using Xcode 3.1 (beta), linking with frameworks libglfw.a,
> Carbon.framework, OpenGL.framework, AGL.framework.

Okay. If I use a full path to the file(s), the fopen works all the
time. The reason the first open worked was because that was called
from a constructor of an object that was global. After that some lib/
framework changes the current working directory and that's why the
successive tries to open the files fail, since they are called later
in the execution of the program.

I guess it's the glfw lib that changes the working directory. I can't
believe Carbon or OpenGL would do that.
 




 4 Posts in Topic:
Strange fopen error
mayoneez <mikko.oksala  2008-05-06 23:24:28 
Re: Strange fopen error
mayoneez <mikko.oksala  2008-05-06 23:49:03 
Re: Strange fopen error
Gregory Weston <uce@[E  2008-05-07 07:37:13 
Re: Strange fopen error
mayoneez <mikko.oksala  2008-05-08 03:33:02 

Post A Reply:
  Go here to Signup

AddThis Feed Button


About - Advertising - Contact - Frequently Asked Questions - Privacy Policy - Terms of Use - Signup

Contact
localhost-V2008-12-19 Wed Jan 7 19:45:31 PST 2009.