forums.ps2dev.org Forum Index forums.ps2dev.org
Homebrew PS2, PSP & PS3 Development Discussions
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

sceIoLseek

 
Post new topic   Reply to topic    forums.ps2dev.org Forum Index -> PSP Development
View previous topic :: View next topic  
Author Message
Treat



Joined: 26 Sep 2004
Posts: 16

PostPosted: Fri May 27, 2005 2:07 pm    Post subject: sceIoLseek Reply with quote

how does the sceIoLseek function work? i tried this

Code:

   fd = sceIoOpen("ms0:/psp/game/myapp/thefile", O_RDONLY);
   
   if(!fd) {
      printf("file not found!\n");
      return;
   }
   
   unsigned int blah;
   int res = sceIoLseek(fd, 0x123, 0);
   printf("sceIoLseek: %d\n", res);
   sceIoRead(fd, (char*)&blah, 4);


output:
sceIoLseek: -7ffdfcdc

read works ok but it always reads the first 4 bytes.
Back to top
View user's profile Send private message
MindWall



Joined: 10 May 2005
Posts: 70

PostPosted: Fri May 27, 2005 2:26 pm    Post subject: Reply with quote

I haven't done coding in years, but aren't you specifying to read 4 bytes to start with?
sceIoRead(fd, (char*)&blah, 4);
Back to top
View user's profile Send private message
Treat



Joined: 26 Sep 2004
Posts: 16

PostPosted: Fri May 27, 2005 2:53 pm    Post subject: Reply with quote

yes, but i want it to read at offset 0x123
Back to top
View user's profile Send private message
Guest






PostPosted: Fri May 27, 2005 3:23 pm    Post subject: Re: sceIoLseek Reply with quote

Treat wrote:
how does the sceIoLseek function work? i tried this

Code:

   unsigned int blah;
   int res = sceIoLseek(fd, 0x123, 0);
   [b]printf("sceIoLseek: %d\n", res);[/b]
   sceIoRead(fd, (char*)&blah, 4);


output:
sceIoLseek: -7ffdfcdc

read works ok but it always reads the first 4 bytes.


Looks like "res" really should be unsigned. Mind changing that so it might be possible to make more sense of the return code ?

I don't know a heck of alot about reading to/from flash. But I wonder if its possible that reads/writes should be in some multiples of a block size ?
Back to top
Treat



Joined: 26 Sep 2004
Posts: 16

PostPosted: Fri May 27, 2005 6:05 pm    Post subject: Reply with quote

unsigned output is: 0x80020324

this works
Code:

void my_seek(int fd, int offset)
{
   char c;
   for(int i = 0; i < offset; ++i)
      sceIoRead(fd, &c, 1);
}


but i rather not do it that way
Back to top
View user's profile Send private message
Guest






PostPosted: Fri May 27, 2005 6:11 pm    Post subject: Reply with quote

For efficiency, you might also consider reading a 512 byte chunk at a time first into a buffer, then do you program reading/seeking from that buffer. Reading one character at a time from memstick could be expensive.

Maybe I am making an assumption here that the IoRead call itself is unbuffered, and that assumption may be incorrect. Anyone know ?
Back to top
Vampire



Joined: 12 Apr 2005
Posts: 138

PostPosted: Fri May 27, 2005 6:34 pm    Post subject: Reply with quote

int sceIoLseek(int fd, long long offset, int whence);

or

s32 sceIoLseek(s32 fd, s64 offset, s32 whence);
Back to top
View user's profile Send private message
Guest






PostPosted: Fri May 27, 2005 6:42 pm    Post subject: Reply with quote

OOOH! That can make a BIG difference! ;)
Back to top
Treat



Joined: 26 Sep 2004
Posts: 16

PostPosted: Fri May 27, 2005 6:52 pm    Post subject: Reply with quote

ahhh, sweet thanks
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    forums.ps2dev.org Forum Index -> PSP Development All times are GMT + 10 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group