kolibrios-fun/contrib/sdk/sources/newlib/libc/sys/ftruncate.c
turbocat 6e3276cb4b NewLib:
- Added basic support for dirent.h;
- Added memory.h for compatibility;
- Added ftruncate() function;
- Fixed date and time structures in ksys_file_info_t.

git-svn-id: svn://kolibrios.org@9954 a494cfbc-eb01-0410-851d-a64ba20cac60
2024-01-12 23:01:16 +00:00

25 lines
384 B
C

#include <errno.h>
#include <sys/types.h>
#include <sys/ksys.h>
#include "glue.h"
#include "io.h"
int
_DEFUN (ftruncate, (fd, len),
int fd _AND
off_t len)
{
__io_handle *ioh;
if ((fd < 0) || (fd >=64))
{
errno = EBADF;
return (-1);
}
ioh = &__io_tab[fd];
if (_ksys_file_set_size(ioh->name, len))
return (-1);
return 0;
}