/* This file is part of Lcrzo.
*/

int lcrzo_file_truncate(lcrzo_file *pfile, 
		      lcrzo_int32 size)
{ int ret;

  if (pfile==NULL) return(LCRZO_ERR_PANULLPTR);

  /* truncate the file */
#if defined LCRZODEF_SYSTEM_Unix
  ret=ftruncate(pfile->fd, size);
  if (ret==-1) return(LCRZO_ERR_FUFTRUNCATE);
#elif defined LCRZODEF_SYSTEM_Windows
  ret=_chsize(pfile->fd, size);
  if (ret==-1) return(LCRZO_ERR_FUCHSIZE);
#else
 #error "Unknown value for LCRZODEF_SYSTEM"
#endif
  
  return(LCRZO_ERR_OK);
}

