| View previous topic :: View next topic |
| Author |
Message |
theHobbit
Joined: 30 Sep 2006 Posts: 65
|
Posted: Thu Jul 26, 2007 10:01 am Post subject: truncate and ftruncate? |
|
|
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 |
|
 |
jimparis
Joined: 10 Jun 2005 Posts: 1179 Location: Boston
|
Posted: Thu Jul 26, 2007 3:24 pm Post subject: |
|
|
Truncate is, ftruncate isn't.
There was some code here but I don't think it was ever merged. |
|
| Back to top |
|
 |
theHobbit
Joined: 30 Sep 2006 Posts: 65
|
Posted: Thu Jul 26, 2007 10:33 pm Post subject: |
|
|
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 |
|
 |
|