Re: Strange fopen error
- From: mayoneez <mikko.oksalahti@xxxxxx>
- Date: Tue, 6 May 2008 23:49:03 -0700 (PDT)
On May 7, 9:24 am, mayoneez <mikko.oksala...@xxxxxx> 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 == 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:
char filename[256];
sprintf(filename, "./level%d.txt", m_current_level + 1);
FILE* fp = fopen(filename, "r");
if(fp) {
...
fclose(fp);
}
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.
.
- Follow-Ups:
- Re: Strange fopen error
- From: Gregory Weston
- Re: Strange fopen error
- References:
- Strange fopen error
- From: mayoneez
- Strange fopen error
- Prev by Date: Re: (Obj-C) One of these things is not like the other...
- Next by Date: Re: Strange fopen error
- Previous by thread: Strange fopen error
- Next by thread: Re: Strange fopen error
- Index(es):
Relevant Pages
|