In my program I'm reading a file from flash using sceIoRead.
I want to read a string from the file that is terminated with a null character, I know the start position of the string, but I'd like to output the string once I've finished reading it.
Ideally, I'd like to be able to just loop until I hit the null character keeping a count, then just read from position - count to position into a string.
I don't think it's possible using sceIoRead to read backwards though is it?
If this is the case, would it be better to just read into a buffer until i hit the null character?
sceIoRead question
Code: Select all
SceOff sceIoLseek(SceUID fd, SceOff offset, int whence);
long sceIoLseek32(SceUID fd, long offset, int whence);
Code: Select all
file = sceIoOpen("flash0:/fileiwant.bla");
filesize = sceIoLseek(file, 0, SCE_SEEK_END); //I dont know the real #defines.. sorry
sceIoLseek(file, 0, SCE_SEEK_SET);
char* buffer = malloc(filesize);
sceIoRead(file, buffer, 1, filesize);
sceIoClose(file);
printf("The first string in the file is %d characters long.\n", strlen(&buffer[0]) );
-
- Posts: 17
- Joined: Thu Aug 04, 2005 9:10 pm