Welcome! Log In Create A New Profile

Advanced

File opening issues...

Posted by pokeglobe 
File opening issues...
March 21, 2010 05:01AM
I cannot... for the life of me, open a file! I looked at so many sources & have done this before.
But it wont work anymore!

I followed the tutorial at codemii:
FILE *f = fopen ("keys.txt", "rb");

// If file doesn't exist or can't open it then we can grab the latest file
if (f == NULL) {
die("Could not open myfile.txt file for reading.\n");
}
else {
char file_line [20];
int line_number = 0;
while (fgets (file_line, 20, f)) {
printf("Line %i: %s\n",line_number, file_line);
line_number++;
}
fclose(f);
}

My SD card is SDHC and I have used it while coding before. Just this time it is failing hard.
I think it might be IOS249 as it is loaded at the start of the application. I used a modified IOS36 1042 with EHC module.

If not, what would the problem be? Does Fatinitdefault still work?

Thanks in advance!

EDIT: It wasn't 249 without SDHC privs because downloading to SD works.
fopen "file" "wb" works fine.

I also tried adding sd:/ before filename and it always reads NULL. :(
I have also tried "r" instead of "rb" And YES the file is on the root of the SD card no typos. I have tried 2/3 files now.



Edited 1 time(s). Last edit at 03/21/2010 05:08AM by pokeglobe.
Re: File opening issues...
March 21, 2010 05:39AM
Huh... That is strange. I won't claim to be the absolute authority, and all I can think of is your comment: "IOS36 1042 with EHC module". Maybe that's the problem?

Can you compile and run the example, exactly? Perhaps it's in the modifications? This has happened to me more times than I would like to admit This has never happened to me.
Re: File opening issues...
March 21, 2010 05:49AM
I changed loading IOS249 (36 with EHC) to IOS36 (70 with patches from DOP-Mii)
Still 100% refuses to open. I have tried many different examples of opening.

Edit: I couldn't get a code to show the if the file opened. aka : If ret = 0 success otherwise show the ret.

I just don't get it, because it writes a file NO problem whatsoever. I have even tested it by deleting and re-trying.
Just refuses to read. Maybe I should update libogc.

Edit: updating libogc and DevkitPPC didn't fix it.
It compiles with no warnings at all.

Maybe it just doesn't like reading SDHC but can write to it?



Edited 2 time(s). Last edit at 03/21/2010 06:14AM by pokeglobe.
Re: File opening issues...
March 21, 2010 06:19AM
fatInitDefault(); ?

sorry did not see - If not, what would the problem be? Does Fatinitdefault still work?




Edited 1 time(s). Last edit at 03/21/2010 06:21AM by scanff.
Re: File opening issues...
March 21, 2010 06:28AM
Something is killing the code. Not sure what it is.
I call miscinit(); from anytitle deleter and thats it. Maybe that screws with it.

Still open to solutions!


Edit: it WAS miscinit(); as soon as I removed the call it found the file!
Just gotta go in there and find the thing that is screwing with it.

Edit: I cannot find the source of the problem... nowhere does it use fat. I checked wiibasics.c and id.c and neither use fat.



Edited 2 time(s). Last edit at 03/21/2010 06:32AM by pokeglobe.
Re: File opening issues...
March 21, 2010 07:07AM
Any title deleter is using ISFS. This could be affecting the standard lib file i/o as ISFS is i/o too. Just a thought as I really don't know much about the ISFS.
Re: File opening issues...
March 21, 2010 07:55AM
I found I just had to use fatinit again and it fixed it.
Sorry, only registered users may post in this forum.

Click here to login