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!!
truncate and ftruncate?
Thanks I have already tryied that:
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?
Code: Select all
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;
}
Well anyone have used it successfully?