added ase_fio_truncate()

This commit is contained in:
2008-11-29 00:43:44 +00:00
parent 59facccc5c
commit 53acab208e
8 changed files with 13166 additions and 11272 deletions

View File

@ -230,6 +230,30 @@ ase_fio_off_t ase_fio_seek (
#endif
}
int ase_fio_truncate (ase_fio_t* fio, ase_fio_off_t size)
{
#ifdef _WIN32
LARGE_INTEGER x;
x.QuadPart = size;
if (SetFilePointerEx(fio->handle,x,NULL,FILE_BEGIN) == FALSE ||
SetEndOfFile(fio->handle) == FALSE) return -1;
return 0;
#else
#if !defined(_LP64) && defined(SYS_ftruncate64)
return syscall (SYS_ftruncate64, fio->handle, size);
#elif defined(SYS_ftruncate)
return syscall (SYS_ftruncate, fio->handle, size);
#elif !defined(_LP64) && defined(HAVE_FTRUNCATE64)
return ftruncate64 (fio->handle, size);
#else
return ftruncate (fio->handle, size);
#endif
#endif
}
ase_ssize_t ase_fio_read (ase_fio_t* fio, void* buf, ase_size_t size)
{
#ifdef _WIN32