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 

truncate and ftruncate?

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



Joined: 30 Sep 2006
Posts: 65

PostPosted: Thu Jul 26, 2007 10:01 am    Post subject: truncate and ftruncate? Reply with quote

Hi, does any one knows if the truncate and ftruncate functions are implemented in the pspsdk? Cuz i get an 'undefined reference to ftruncate' error whenever I try to compile a simple test with these function!!

Hope anyone can help. Thanks in advance!!
Back to top
View user's profile Send private message
jimparis



Joined: 10 Jun 2005
Posts: 1179
Location: Boston

PostPosted: Thu Jul 26, 2007 3:24 pm    Post subject: Reply with quote

Truncate is, ftruncate isn't.
There was some code here but I don't think it was ever merged.
Back to top
View user's profile Send private message
theHobbit



Joined: 30 Sep 2006
Posts: 65

PostPosted: Thu Jul 26, 2007 10:33 pm    Post subject: Reply with quote

Thanks I have already tryied that:

Code:
int ftruncate(int fd, off_t length)
{
   int ret;
   SceOff oldpos;
   if (!__PSP_IS_FD_VALID(fd)) {
      errno = EBADF;
      return -1;
   }

   switch(__psp_descriptormap[fd]->type)
   {
      case __PSP_DESCRIPTOR_TYPE_FILE:
         if (__psp_descriptormap[fd]->filename != NULL) {
            if (!(__psp_descriptormap[fd]->flags & (O_WRONLY | O_RDWR)))
               break;
            return truncate(__psp_descriptormap[fd]->filename, length);
            /* ANSI sez ftruncate doesn't move the file pointer */
         }
         break;
      case __PSP_DESCRIPTOR_TYPE_TTY:
      case __PSP_DESCRIPTOR_TYPE_PIPE:
      case __PSP_DESCRIPTOR_TYPE_SOCKET:
      default:
         break;
   }

   errno = EINVAL;
   return -1;
}


but i'm a little lost. Is it some kind of patch to the pspsdk cuz I just pasted it in my code but cant compile it, i get several undefined references to: __PSP_DESCRIPTOR_TYPE, __psp_descriptormap, etc...

Well anyone have used it successfully?
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